[1/2] server: Store the time of the socket connection

Bruno Jesus 00cpxxx at gmail.com
Tue May 27 19:47:21 CDT 2014


Rebased version of a patch from Erich Hoover, all kudos to him.

This patch changes the server protocol.def file.
-------------- next part --------------

---
 server/protocol.def | 1 +
 server/sock.c       | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/server/protocol.def b/server/protocol.def
index fec5e75..1e83862 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1250,6 +1250,7 @@ enum server_fd_type
     int family;                 /* family, see socket manpage */
     int type;                   /* type, see socket manpage */
     int protocol;               /* protocol, see socket manpage */
+    unsigned int connect_time;  /* time the socket was connected (tick count) */
 @END
 
 
diff --git a/server/sock.c b/server/sock.c
index 5ffb1fe..9604517 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -104,6 +104,7 @@ struct sock
     unsigned int        message;     /* message to send */
     obj_handle_t        wparam;      /* message wparam (socket handle) */
     int                 errors[FD_MAX_EVENTS]; /* event errors */
+    unsigned int        connect_time;/* time the socket was connected (tick count) */
     struct sock        *deferred;    /* socket that waits for a deferred accept */
     struct async_queue *read_q;      /* queue for asynchronous reads */
     struct async_queue *write_q;     /* queue for asynchronous writes */
@@ -398,6 +399,7 @@ static void sock_poll_event( struct fd *fd, int event )
             /* we got connected */
             sock->state |= FD_WINE_CONNECTED|FD_READ|FD_WRITE;
             sock->state &= ~FD_CONNECT;
+            sock->connect_time = get_tick_count();
         }
     }
     else if (sock->state & FD_WINE_LISTENING)
@@ -615,6 +617,7 @@ static void init_sock(struct sock *sock)
     sock->window  = 0;
     sock->message = 0;
     sock->wparam  = 0;
+    sock->connect_time = 0;
     sock->deferred = NULL;
     sock->read_q  = NULL;
     sock->write_q = NULL;
@@ -722,6 +725,7 @@ static struct sock *accept_socket( obj_handle_t handle )
         acceptsock->family  = sock->family;
         acceptsock->window  = sock->window;
         acceptsock->message = sock->message;
+        acceptsock->connect_time = get_tick_count();
         if (sock->event) acceptsock->event = (struct event *)grab_object( sock->event );
         acceptsock->flags = sock->flags;
         if (!(acceptsock->fd = create_anonymous_fd( &sock_fd_ops, acceptfd, &acceptsock->obj,
@@ -773,6 +777,7 @@ static int accept_into_socket( struct sock *sock, struct sock *acceptsock )
     acceptsock->type    = sock->type;
     acceptsock->family  = sock->family;
     acceptsock->wparam  = 0;
+    acceptsock->connect_time = get_tick_count();
     acceptsock->deferred = NULL;
     release_object( acceptsock->fd );
     acceptsock->fd = newfd;
@@ -1084,6 +1089,7 @@ DECL_HANDLER(get_socket_info)
     reply->family   = sock->family;
     reply->type     = sock->type;
     reply->protocol = sock->proto;
+    reply->connect_time = sock->connect_time;
 
     release_object( &sock->obj );
 }
-- 
1.8.3.2



More information about the wine-patches mailing list