]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 959] Refclock on Windows not properly releasing recvbuffs
authorDanny Mayer <mayer@ntp.org>
Mon, 28 Jan 2008 02:39:10 +0000 (21:39 -0500)
committerDanny Mayer <mayer@ntp.org>
Mon, 28 Jan 2008 02:39:10 +0000 (21:39 -0500)
bk: 479d404eNavIJfNqME3wa90G6Eb1Lg

ChangeLog
libntp/recvbuff.c
ports/winnt/ntpd/ntp_iocompletionport.c

index 2dc0755228cd4211c6e9579f384c19a047e88e3e..f0e2de5380271928da822c83eba64d730d98846d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 959] Refclock on Windows not properly releasing recvbuffs
 * [Bug 993] Fix memory leak when fetching system messages
 * much cleanup, fixes, and changes from Dave Mills.
 * ntp_control.c: LEAPTAB is a filestamp, not an unsigned.  From Dave Mills.
index 9511c8fe50fce86ab33f9ccde13e0424fd8acfeb..507330c18bb32cc8acfecc32b936d74f9deb5555 100644 (file)
@@ -134,10 +134,6 @@ freerecvbuf(recvbuf_t *rb)
        if (rb->used != 0)
                msyslog(LOG_ERR, "******** freerecvbuff non-zero usage: %d *******", rb->used);
        ISC_LIST_APPEND(free_recv_list, rb, link);
-#if defined SYS_WINNT
-       rb->wsabuff.len = RX_BUFF_SIZE;
-       rb->wsabuff.buf = (char *) rb->recv_buffer;
-#endif
        free_recvbufs++;
        UNLOCK();
 }
index 078e60b9faafc7676644123860363942f637d62a..35420ed545d9a1906f5209f82b123755962b8c86 100644 (file)
@@ -51,9 +51,6 @@ static int OnSocketRecv(DWORD, IoCompletionInfo *, DWORD, int);
 static int OnIoReadComplete(DWORD, IoCompletionInfo *, DWORD, int);
 static int OnWriteComplete(DWORD, IoCompletionInfo *, DWORD, int);
 
-
-#define BUFCHECK_SECS  10
-static void    TransmitCheckThread(void *NotUsed);
 static HANDLE hHeapHandle = NULL;
 
 static HANDLE hIoCompletionPort = NULL;
@@ -296,14 +293,11 @@ uninit_io_completion_port(
 
 static int QueueIORead( struct refclockio *rio, recvbuf_t *buff, IoCompletionInfo *lpo) {
 
-       memset(lpo, 0, sizeof(IoCompletionInfo));
-       memset(buff, 0, sizeof(recvbuf_t));
-
        lpo->request_type = CLOCK_READ;
        lpo->recv_buf = buff;
 
        buff->fd = rio->fd;
-       if (!ReadFile((HANDLE) buff->fd, &buff->recv_buffer, sizeof(buff->recv_buffer), NULL, (LPOVERLAPPED) lpo)) {
+       if (!ReadFile((HANDLE) buff->fd, buff->wsabuff.buf, buff->wsabuff.len, NULL, (LPOVERLAPPED) lpo)) {
                DWORD Result = GetLastError();
                switch (Result) {                               
                case NO_ERROR :
@@ -332,6 +326,9 @@ OnIoReadComplete(DWORD i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
        recvbuf_t *buff;
        recvbuf_t *newbuff;
        struct refclockio * rio = (struct refclockio *) i;
+       l_fp arrival_time;
+
+       get_systime(&arrival_time);
 
        /*
         * Get the recvbuf pointer from the overlapped buffer.
@@ -354,7 +351,7 @@ OnIoReadComplete(DWORD i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
                 * ignore 0 bytes read due to timeout's and closure on fd
                 */
                if (Bytes > 0 && errstatus != WSA_OPERATION_ABORTED) {
-                       get_systime(&buff->recv_time);
+                       memcpy(&buff->recv_time, &arrival_time, sizeof(arrival_time));  
                        buff->recv_length = (int) Bytes;
                        buff->receiver = rio->clock_recv;
                        buff->dstadr = NULL;
@@ -492,7 +489,6 @@ OnSocketRecv(DWORD i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
         * Make sure we have a buffer
         */
        if (buff == NULL) {
-//             FreeHeap(lpo, "OnSocketRecv: Socket Closed");
                return (1);
        }