On Tue, 16 Feb 2010, Maurilio Longo wrote:
Hi Maurilio,
> I'd like to add this code to hbinet.c
> HB_FUNC( HB_INETSHUTDOWN )
> {
> PHB_SOCKET_STRUCT socket = HB_PARSOCKET( 1 );
> if( socket )
> {
> if( socket->sd != HB_NO_SOCKET )
> {
> hb_retni( hb_socketShutdown( socket->sd, HB_SOCKET_SHUT_RDWR ) );
> #if 0
> #ifdef HB_INET_LINUX_INTERRUPT
> kill( 0, HB_INET_LINUX_INTERRUPT );
> #endif
> #endif
> }
> else
> hb_retni( -1 );
> }
> else
> hb_inetErrRT();
> }
> to be able to shutdown a socket before closing it,
Have you noticed that hb_socketShutdown() is called automatically
in hb_inetClose() and when socket is closed automatically by destructor?
Why you need to call it explicitly?
It's redundant. All hb_inet*() sockets are
> I've commented out #ifdef
> HB_INET_LINUX_INTERRUPT which I don't know what it really does.
HB_INET_LINUX_INTERRUPT is a macro which enables code using signals
to interrupt socket operation. Giancarlo used it in original xHarbour
socket implementation and as I can see it's still there. In this
context it's used to wake up other threads waiting on the same socket.
I disabled it in default Harbour builds because our hb_fs* API is still
not safe for interrupting by asynchronous signals so it may cause
problems on kernels which do not resume interrupted disk operations
(POSIX compatible behavior).
HB_INET_LINUX_INTERRUPT is enough guard to disable this code and you do
not have to add #if 0 yet.
> Do you think it's ok to commit it like this?
Just let me know if you why you need it.
I have nothing against adding HB_INETSHUTDOWN() function but it
should support for 2-nd parameter so user can use it to selectively
close only read or write streams.
> And, by the way, after this call, a call to hb_InetClose() would shutdown
> socket again, which I don't think would create problems, but I don't have a
> full vision of sockets in all supported platforms.
Personally I'm very interested why this explicit call to shutdown() just
before close[socket]() was added to xHarbour and what was the intentional
behavior of this code. I replicated it in HB_INET*() functions in Harbour
to keep it compatible.
best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour