This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Cygwin handle leak in net.cc


Chris,

I believe there's a handle leak occurring in 
net.cc.

The functions recv/recfrom and send/sendto use
the wsock_event class that obtains a handle using
WSACreateEvent.

wsock_event::prepare allocates the handle.

When this class is used, if wsock_event::wait isn't
invoked, the handle won't be freed.

I observed this in the recv function.

  In Windows NT's Task Manager, I was watching 
fetchmail's handle count, and it quickly grew to 60,000.
I modified the fetchmail source to obtain its handle
count using NtQueryInformationProcess from NTDLL.DLL,
and recv() was the culprit.

If the wsock_event class was modified with a destructor
that did this:

    wsock_event::~wsock_event
    {
        if (event)
        {
               WSACloseEvent(event);
               event=0;
        }
    }

I think this would fix the problem.

This would ensure the handle is freedl when 
the object goes out of scope.

Joe


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]