void complete_connect_socket(struct socket *socket, struct uri *uri, socket_connect_T done) { struct connect_info *connect_info = socket->connect_info; if (connect_info && connect_info->uri) { /* Remember whether the server supported TLS or not. * Then the next request can immediately use the right * protocol. This is important for HTTP POST requests * because it is not safe to silently retry them. The * uri parameter is normally NULL here so don't use it. */ if (socket->no_tls) add_blacklist_entry(connect_info->uri, SERVER_BLACKLIST_NO_TLS); else del_blacklist_entry(connect_info->uri, SERVER_BLACKLIST_NO_TLS); } /* This is a special case used by the HTTP implementation to acquire an * SSL link for handling CONNECT requests. */ if (!connect_info) { assert(uri && socket); connect_info = init_connection_info(uri, socket, done); if (!connect_info) { socket->ops->done(socket, connection_state(S_OUT_OF_MEM)); return; } socket->connect_info = connect_info; } #ifdef CONFIG_SSL /* Check if the connection should run over an encrypted link */ if (socket->need_ssl && !socket->ssl && ssl_connect(socket) < 0) return; #endif if (connect_info->done) connect_info->done(socket); done_connection_info(socket); }
void done_socket(struct socket *socket) { struct socket_weak_ref *ref; close_socket(socket); if (socket->connect_info) done_connection_info(socket); mem_free_set(&socket->read_buffer, NULL); mem_free_set(&socket->write_buffer, NULL); foreach(ref, socket_weak_refs) { if (ref->socket == socket) ref->socket = NULL; } }
void done_socket( struct socket *socket ) { int eax; struct socket_weak_ref *ref; close_socket( socket ); if ( socket->connect_info ) { ref = &socket[0].fd; done_connection_info( &socket[0] ); } ref = &socket->read_buffer->done[0]; if ( socket->read_buffer ) mem_free( (void*)ref[0].next ); ref = &socket->write_buffer[0]; socket->read_buffer = 0; if ( socket->write_buffer ) mem_free( (void*)ref[0].next ); socket->write_buffer = 0; ref = &socket_weak_refs.next[0]; if ( socket_weak_refs.next != socket_weak_refs.next ) { do { if ( ref->socket == socket[0].fd ) { ref->socket = 0; ref = &ref; if ( ref->next != socket_weak_refs.next ) continue; else break; } else { ref = &ref; } } while ( ref->next != socket_weak_refs.next ); } return; }