This is the mail archive of the cygwin-developers@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]
Other format: [Raw text]

Re: [tolj@wapme-systems.de: Re: Problem with accept?!!


On Tue, Jun 03, 2003 at 01:19:21PM +0200, Thomas Pfaff wrote:
> Corinna Vinschen wrote:
> >I was already experimenting with the old WSASetBlockingHook stuff but
> >it doesn't work well.  So it just occured to me that we could do sth.
> >similar as in cygwin_select.  What about creating *another* socket in
> >the main function which only function is to be able to be select()ed.
> >Then, as soon as signal_arrived is triggered, this socket gets closed
> >by the main thread.  The result would be that select() returns and we
> >can leave the accept/connect_thread gracefully instead of terminating
> >it.
> >
> >Good?  Bad?  Ugly?
> 
> I do not know if i understand you right but:
> 
> If you see a chance to use cygwin_select instead of winsock_select than 
> there is no need to terminate the threads since they must not be used at 
> all, the accept/connect thread stuff can be moved in the mainthread 
> since cygwin_select is already interruptible.

Well... I was a bit reluctant to use cygwin_select directly since it
produces so much overhead and I didn't want to mess something up.

What I meant originally was your code plus roughly this:

  in fhandler_socket::accept

    sock2 = socket()
    sock_thread_data ad = { ..., sock2 };
    HANDLE wait_events[2] = { *thread, signal_arrived };
    if (WaitForMultipleObjects(2, wait_events, FALSE, INFINITE)
        != WAIT_OBJECT_0)
      {
        connect(sock2); /* Trigger select() */
      }
    thread->detach ();
    ...

  in accept_thread

    WINSOCK_FD_ZERO(&rdfds);
    WINSOCK_FD_SET((HANDLE)std->socket, &rdfds);
    WINSOCK_FD_SET((HANDLE)std->sock2, &rdfds);
    std->ret = WINSOCK_SELECT();
    std->winsock_err =  WINSOCK_FD_ISSET(sock2) ?
    				WSAEINPROGRESS : WSAGetLastError ();


What do you think?

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.


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