static void set_nonblocking(int fd)
{
+ int v = 0;
#if defined(WIN32)
+ long nonblocking=1;
+ v = ioctlsocket(fd, FIONBIO,&nonblocking);
#else
- unsigned v;
v = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, v | O_NONBLOCK);
#endif //FIXME
if (revents & POLLIN) {
if (rpc_read_from_socket(rpc) != 0) {
- rpc_disconnect_requeue(rpc);
+ rpc_disconnect_requeue(rpc);
return 0;
}
}
rpc->connect_data = private_data;
set_nonblocking(rpc->fd);
-
- if (connect(rpc->fd, (struct sockaddr *)&s, socksize) != 0 && errno != EINPROGRESS) {
+#if defined(WIN32)
+ if (connect(rpc->fd, (struct sockaddr *)&s, socksize) == 0 && GetLastError() != WSAEINPROGRESS )
+#else
+ if (connect(rpc->fd, (struct sockaddr *)&s, socksize) != 0 && errno != EINPROGRESS)
+#endif
+ {
rpc_set_error(rpc, "connect() to server failed");
return -1;
}
{
return (struct sockaddr *)&rpc->udp_src;
}
+
+int rpc_queue_length(struct rpc_context *rpc)
+{
+ int i=0;
+ struct rpc_pdu *pdu;
+
+ for(pdu = rpc->outqueue; pdu; pdu = pdu->next) {
+ i++;
+ }
+ for(pdu = rpc->waitpdu; pdu; pdu = pdu->next) {
+ i++;
+ }
+ return i;
+}