[noPoll] nopoll / own master listener

Francis Brosnan Blázquez francis en aspl.es
Mie Abr 1 20:20:16 CEST 2015


El mié, 01-04-2015 a las 17:45 +0200, Matthias Reich escribió:
> Hi Francis,

Hi Matthias,

> I've restarted trying to use nopoll in my own project, however, to save 
> time, I chose not to rewrite code, but use my previous threaded server 
> model to accept connections, where I've implemented a server_thread with 
> 10 ears such that it starts a new thread with each successful incoming 
> connection and leaves everything to a "slave" thread to deal with it.
> 
> 
> Ideally, I would just replace the slave thread with a thread that 
> establishes the websocket connection from the existing connected socket, 
> however, I ran into an issue.
> 
> My client currently is a simple javascript/html5 on a webpage that uses 
> the built in websocket protocol to establish a connection to my 
> libnopoll-powered server.

Ok,

> 1) When I run a (a simplyfied - no SSL) version of 
> nopoll-regression-listener.c on a certain port, I can use the 
> web-application to establish a connection AND send messages to the 
> listener. It does end the connect process with a warning
> 
> (proc 18160): (warning) nopoll_conn.c:2410 (nopoll_conn_get_msg) 
> Connection id=3 without data, errno=11 : Resource temporarily 
> unavailable, returning no message
> 
> but I can send stuff over the connection afterwards and close it from 
> the client, if wanted.

Ok, you can ignore this message. For some reason, your browser is
sending data but not enough to have nopoll_conn_get_msg returning to you
something meaningful...

> 2) When I run the listener (from socket) in my own application, the 
> exact same web-app establishes a connection, runs through the handshake, 
> gets an accept and then fails with
> 
> (proc 10235): (critical) nopoll_conn.c:1626 (__nopoll_conn_receive) 
> unable to readn=2, error code was: 0 (Error 0) (shutting down connection)

Uhmn..don't know because I don't have the complete example, but it looks
like you should use nopoll_listener_from_socket, and pass to it the
socket accepted...

> The only difference is that my application doesn't have any nopoll- 
> MASTER_LISTENER, but only the connection listener that I create from the 
> socket just after the connection gets accept()-ed by the server-thread.

Certainly, it looks like you should give a try to
nopoll_listener_from_socket...

> I tried adding a call to nopoll_conn_accept_complete() using a dummy 
> master listener which I create by nopoll_listener_from_socket with the 
> socket (still in use) from the bind/listen/accept scheme in the other 
> thread.
> 
> Still no avail.

Ok, if the socket is already accepted and the handshake was completed,
avoid any function that does that. In this case it should work by just
calling to nopoll_listener_from_socket and start working with it...

> The critical points might be:
> Why does the one application return with errno=11 and the other with 
> errno=0 ?

Difficult to answer without having the code... but for the errno=11 keep
in mind that is quite common (it is not an error in fact) and errno=0
means no error.

> Do I have to add some state information transfer, when I start the new 
> thread? Is this a thread context thing?

No. It should work just fine by calling nopoll_listener_from_socket...

> Any help would be appreciated.
> 
> (I would have posted this to the list, but still wait for approval)

Ok, I think we have some problems with the mailing list...I'll contact
the system administration to review it because I didn't receive any
pending mailing list message...

Let me know your progress,
Best Regards,

> Cheers,
> Matthias
> 
> 
> 

-- 
Francis Brosnan Blázquez <francis en aspl.es>
ASPL
91 134 14 22 - 91 134 14 45 - 91 116 07 57

AVISO LEGAL
 
En virtud de lo dispuesto en la Ley Orgánica 15/1999, de 13 de
diciembre, de Protección de Datos de Carácter Personal, le informamos de
que sus datos de carácter personal, recogidos de fuentes accesibles al
público o datos que usted nos ha facilitado previamente, proceden de
bases de datos propiedad de Advanced Software Production Line, S.L.
(ASPL).
 
ASPL garantiza que los datos serán tratados con la finalidad de mantener
las oportunas relaciones comerciales o promocionales con usted o la
entidad que usted representa. No obstante, usted puede ejercitar sus
derechos de acceso, rectificación, cancelación y oposición dispuestos en
la mencionada Ley Orgánica, notificándolo por escrito a ASPL -
Protección Datos, C/Antonio Suárez 10 A-102, 28802, Alcalá de Henares
(Madrid).






Más información sobre la lista de distribución noPoll