X-Git-Url: http://git.samba.org/?p=samba.git;a=blobdiff_plain;f=source%2Fsmbd%2Fprocess_single.c;h=554f3e91daa47834d556a3b7d4921715f0b3c73f;hp=1cba3faee3f4de625af0eb80ec5132157fb2865f;hb=a8ec53c81ad939156654c9ad99a53aa2d679f711;hpb=0e1f5e66d37deb7a77ae9f545e60685428fd9d21 diff --git a/source/smbd/process_single.c b/source/smbd/process_single.c index 1cba3faee3f..554f3e91daa 100644 --- a/source/smbd/process_single.c +++ b/source/smbd/process_single.c @@ -39,11 +39,8 @@ static void single_accept_connection(struct event_context *ev, struct fd_event * int accepted_fd; struct sockaddr addr; socklen_t in_addrlen = sizeof(addr); - struct fd_event fde; - struct timed_event idle; struct server_socket *server_socket = srv_fde->private; struct server_connection *conn; - TALLOC_CTX *mem_ctx; /* accept an incoming connection. */ accepted_fd = accept(srv_fde->fd,&addr,&in_addrlen); @@ -53,61 +50,11 @@ static void single_accept_connection(struct event_context *ev, struct fd_event * return; } - mem_ctx = talloc_init("server_service_connection"); - if (!mem_ctx) { - DEBUG(0,("talloc_init(server_service_connection) failed\n")); - return; - } - - conn = talloc_p(mem_ctx, struct server_connection); + conn = server_setup_connection(ev, server_socket, accepted_fd, t); if (!conn) { - DEBUG(0,("talloc_p(mem_ctx, struct server_service_connection) failed\n")); - talloc_destroy(mem_ctx); - return; - } - - ZERO_STRUCTP(conn); - conn->mem_ctx = mem_ctx; - - fde.private = conn; - fde.fd = accepted_fd; - fde.flags = EVENT_FD_READ; - fde.handler = server_io_handler; - - idle.private = conn; - idle.next_event = t + 300; - idle.handler = server_idle_handler; - - conn->event.ctx = ev; - conn->event.fde = &fde; - conn->event.idle = &idle; - conn->event.idle_time = 300; - - conn->server_socket = server_socket; - conn->service = server_socket->service; - - /* TODO: we need a generic socket subsystem */ - conn->socket = talloc_p(conn->mem_ctx, struct socket_context); - if (!conn->socket) { - DEBUG(0,("talloc_p(conn->mem_ctx, struct socket_context) failed\n")); - talloc_destroy(mem_ctx); + DEBUG(0,("server_setup_connection(ev, server_socket, accepted_fd) failed\n")); return; } - conn->socket->private_data = NULL; - conn->socket->ops = NULL; - conn->socket->client_addr = NULL; - conn->socket->pkt_count = 0; - conn->socket->fde = conn->event.fde; - - /* create a smb server context and add it to out event - handling */ - server_socket->service->ops->accept_connection(conn); - - /* accpect_connection() of the service may changed idle.next_event */ - conn->event.fde = event_add_fd(ev,&fde); - conn->event.idle = event_add_timed(ev,&idle); - - conn->socket->fde = conn->event.fde; DLIST_ADD(server_socket->connection_list,conn); @@ -122,9 +69,7 @@ static void single_terminate_connection(struct server_connection *conn, const ch { DEBUG(0,("single_terminate_connection: reason[%s]\n",reason)); conn->service->ops->close_connection(conn,reason); - close(conn->event.fde->fd); - event_remove_fd(conn->event.ctx, conn->event.fde); - event_remove_timed(conn->event.ctx, conn->event.idle); + server_destroy_connection(conn); } static int single_get_id(struct smbsrv_request *req)