Skip to content

Commit

Permalink
Change FD to Handle
Browse files Browse the repository at this point in the history
  • Loading branch information
somdoron committed Nov 8, 2014
1 parent 53d7a1f commit 360861d
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 41 deletions.
6 changes: 6 additions & 0 deletions src/NetMQ/zmq/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ public enum ZmqSocketOptions
SendBuffer = 11,
ReceivevBuffer = 12,
ReceiveMore = 13,

[Obsolete("Use Handle")]
FD = 14,
Handle = 14,



Events = 15,
Type = 16,
Linger = 17,
Expand Down
2 changes: 1 addition & 1 deletion src/NetMQ/zmq/Mailbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public Mailbox(String name)
m_name = name;
}

public System.Net.Sockets.Socket FD
public System.Net.Sockets.Socket Handle
{
get { return m_signaler.Handle; }
}
Expand Down
8 changes: 4 additions & 4 deletions src/NetMQ/zmq/Reaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public Reaper(Ctx ctx, int threadId)

mailbox = new Mailbox(m_name);

m_mailboxHandle = mailbox.FD;
m_poller.AddFD(m_mailboxHandle, this);
m_mailboxHandle = mailbox.Handle;
m_poller.AddHandle(m_mailboxHandle, this);
m_poller.SetPollin(m_mailboxHandle);
}

Expand Down Expand Up @@ -119,7 +119,7 @@ protected void ProcessStop()
if (m_sockets == 0)
{
SendDone();
m_poller.RemoveFD(m_mailboxHandle);
m_poller.RemoveHandle(m_mailboxHandle);
m_poller.Stop();
}
}
Expand All @@ -145,7 +145,7 @@ protected void ProcessReaped()
if (m_sockets == 0 && m_terminating)
{
SendDone();
m_poller.RemoveFD(m_mailboxHandle);
m_poller.RemoveHandle(m_mailboxHandle);
m_poller.Stop();

}
Expand Down
14 changes: 7 additions & 7 deletions src/NetMQ/zmq/SocketBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ public Object GetSocketOptionX(ZmqSocketOptions option)
return m_rcvMore;
}

if (option == ZmqSocketOptions.FD)
if (option == ZmqSocketOptions.Handle)
{
return m_mailbox.FD;
return m_mailbox.Handle;
}

if (option == ZmqSocketOptions.Events)
Expand Down Expand Up @@ -876,8 +876,8 @@ internal void StartReaping(Utils.Poller poller)
{
// Plug the socket to the reaper thread.
m_poller = poller;
m_handle = m_mailbox.FD;
m_poller.AddFD(m_handle, this);
m_handle = m_mailbox.Handle;
m_poller.AddHandle(m_handle, this);
m_poller.SetPollin(m_handle);

// Initialise the termination and check whether it can be deallocated
Expand Down Expand Up @@ -1059,7 +1059,7 @@ private void CheckDestroy()
{

// Remove the socket from the reaper's poller.
m_poller.RemoveFD(m_handle);
m_poller.RemoveHandle(m_handle);
// Remove the socket from the context.
DestroySocket(this);

Expand Down Expand Up @@ -1288,9 +1288,9 @@ public override String ToString()
return base.ToString() + "[" + m_options.SocketId + "]";
}

public Socket FD
public Socket Handle
{
get { return m_mailbox.FD; }
get { return m_mailbox.Handle; }
}

public String GetTypeString()
Expand Down
5 changes: 2 additions & 3 deletions src/NetMQ/zmq/Transports/Pgm/PgmSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,9 @@ public void InCompleted(SocketError socketError, int bytesTransferred)
private void Error()
{
Debug.Assert(m_session != null);
//m_socket.EventDisconnected(m_endpoint, m_handle);
m_session.Detach();

// Cancel all fd subscriptions.

m_ioObject.RemoveSocket(m_handle);

// Disconnect from I/O threads poller object.
Expand Down
6 changes: 3 additions & 3 deletions src/NetMQ/zmq/Transports/StreamEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ enum Action



public StreamEngine(AsyncSocket fd, Options options, String endpoint)
public StreamEngine(AsyncSocket handle, Options options, String endpoint)
{
m_handle = fd;
m_handle = handle;
m_insize = 0;
m_ioEnabled = false;
m_sendingState = SendState.Idle;
Expand Down Expand Up @@ -222,7 +222,7 @@ private void Unplug()
Debug.Assert(m_plugged);
m_plugged = false;

// Cancel all fd subscriptions.
// remove handle from proactor.
if (m_ioEnabled)
{
m_ioObject.RemoveSocket(m_handle);
Expand Down
22 changes: 11 additions & 11 deletions src/NetMQ/zmq/Utils/Poller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public PollSet(Socket socket, IPollEvents handler)
}
}
// This table stores data for registered descriptors.
private readonly List<PollSet> m_fdTable;
private readonly List<PollSet> m_handles;

private readonly List<PollSet> m_addList;

Expand Down Expand Up @@ -77,7 +77,7 @@ public Poller(String name)
m_stopping = false;
m_stopped = false;

m_fdTable = new List<PollSet>();
m_handles = new List<PollSet>();
m_addList = new List<PollSet>();
}

Expand All @@ -95,16 +95,16 @@ public void Destroy()
}
}

public void AddFD(Socket fd, IPollEvents events)
public void AddHandle(Socket handle, IPollEvents events)
{
m_addList.Add(new PollSet(fd, events));
m_addList.Add(new PollSet(handle, events));

m_checkError.Add(fd);
m_checkError.Add(handle);

AdjustLoad(1);
}

public void RemoveFD(Socket handle)
public void RemoveHandle(Socket handle)
{
PollSet pollSet;

Expand All @@ -116,7 +116,7 @@ public void RemoveFD(Socket handle)
}
else
{
pollSet = m_fdTable.First(p => p.Socket == handle);
pollSet = m_handles.First(p => p.Socket == handle);
pollSet.Cancelled = true;

m_retired = true;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void Loop()
{
foreach (var pollSet in m_addList)
{
m_fdTable.Add(pollSet);
m_handles.Add(pollSet);
}
m_addList.Clear();

Expand All @@ -193,7 +193,7 @@ public void Loop()
continue;
}

foreach (var pollSet in m_fdTable)
foreach (var pollSet in m_handles)
{
if (pollSet.Cancelled)
{
Expand Down Expand Up @@ -251,9 +251,9 @@ public void Loop()

if (m_retired)
{
foreach (var item in m_fdTable.Where(k => k.Cancelled).ToList())
foreach (var item in m_handles.Where(k => k.Cancelled).ToList())
{
m_fdTable.Remove(item);
m_handles.Remove(item);
}

m_retired = false;
Expand Down
6 changes: 3 additions & 3 deletions src/NetMQ/zmq/Utils/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public bool Select(SelectItem[] items, int itemsCount, int timeout)

if (pollItem.Socket != null)
{
if (pollItem.Event != PollEvents.None && pollItem.Socket.FD.Connected)
if (pollItem.Event != PollEvents.None && pollItem.Socket.Handle.Connected)
{
m_checkRead.Add(pollItem.Socket.FD);
m_checkRead.Add(pollItem.Socket.Handle);
}
}
else
Expand All @@ -119,7 +119,7 @@ public bool Select(SelectItem[] items, int itemsCount, int timeout)
{
Socket.Select(m_checkRead, m_checkWrite, m_checkError, currentTimeoutMicroSeconds);
}
catch (SocketException ex)
catch (SocketException)
{
throw new FaultException();
}
Expand Down
12 changes: 3 additions & 9 deletions src/NetMQ/zmq/Utils/Signaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ You should have received a copy of the GNU Lesser General Public License
using System.Net;
using System.Runtime.InteropServices;

// This is a cross-platform equivalent to signal_fd. However, as opposed
// to signal_fd there can be at most one signal in the signaler at any
// given moment. Attempt to send a signal before receiving the previous
// one will result in undefined behaviour.

namespace NetMQ.zmq.Utils
{
class Signaler
Expand All @@ -47,9 +42,8 @@ public Signaler()
m_receiveDummy = new byte[1];

// Create the socketpair for signaling.
MakeFDpair();

// Set both fds to non-blocking mode.
MakeSocketsPair();

m_writeSocket.Blocking = false;
m_readSocket.Blocking = false;
}
Expand Down Expand Up @@ -84,7 +78,7 @@ public void Close()

// Creates a pair of filedescriptors that will be used
// to pass the signals.
private void MakeFDpair()
private void MakeSocketsPair()
{
using (Socket listner = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Unspecified))
{
Expand Down

0 comments on commit 360861d

Please sign in to comment.