From: Danny Mayer Date: Mon, 28 Jan 2008 02:39:10 +0000 (-0500) Subject: [Bug 959] Refclock on Windows not properly releasing recvbuffs X-Git-Tag: NTP_4_2_5P111~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2316860b94c32469c0b6cf9cf4a28afadcc8934b;p=thirdparty%2Fntp.git [Bug 959] Refclock on Windows not properly releasing recvbuffs bk: 479d404eNavIJfNqME3wa90G6Eb1Lg --- diff --git a/ChangeLog b/ChangeLog index 2dc075522..f0e2de538 100644 --- 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. diff --git a/libntp/recvbuff.c b/libntp/recvbuff.c index 9511c8fe5..507330c18 100644 --- a/libntp/recvbuff.c +++ b/libntp/recvbuff.c @@ -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(); } diff --git a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c index 078e60b9f..35420ed54 100644 --- a/ports/winnt/ntpd/ntp_iocompletionport.c +++ b/ports/winnt/ntpd/ntp_iocompletionport.c @@ -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); }