Re: [Nbd] [PATCH 1/3] nbd-server: refactor out common code
- To: nbd-general@lists.sourceforge.net
- Subject: Re: [Nbd] [PATCH 1/3] nbd-server: refactor out common code
- From: Wouter Verhelst <w@...112...>
- Date: Wed, 12 Jun 2013 12:02:22 +0200
- Message-id: <51B8472E.7090408@...112...>
- In-reply-to: <7b76c32ad2b6d9eb44d75176417e37f187456ec4.1370964005.git.tuomasjjrasanen@...1261...>
- References: <7b76c32ad2b6d9eb44d75176417e37f187456ec4.1370964005.git.tuomasjjrasanen@...1261...>
Hi Tuomas,
On 11-06-13 17:49, Tuomas Räsänen wrote:
> Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@...1261...>
> ---
> nbd-server.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
This still failed to apply cleanly; I'm not sure why. I just applied it
manually instead, by copy/pasting from the patch.
The other two in this batch weren't problematic.
> diff --git a/nbd-server.c b/nbd-server.c
> index 9b529ae..944ee69 100644
> --- a/nbd-server.c
> +++ b/nbd-server.c
> @@ -2354,12 +2354,17 @@ handler_err:
> }
>
> static void
> -handle_oldstyle_connection(GArray *servers, int net, SERVER *serve)
> +handle_oldstyle_connection(GArray *servers, int sock, SERVER *serve)
> {
> + int net;
> CLIENT *client = NULL;
> int sock_flags_old;
> int sock_flags_new;
>
> + net = socket_accept(sock);
> + if (net < 0)
> + return;
> +
> if(serve->max_connections > 0 &&
> g_hash_table_size(children) >= serve->max_connections) {
> msg(LOG_INFO, "Max connections reached");
> @@ -2517,8 +2522,6 @@ out:
> * Loop through the available servers, and serve them. Never returns.
> **/
> void serveloop(GArray* servers) {
> - struct sockaddr_storage addrin;
> - socklen_t addrinlen=sizeof(addrin);
> int i;
> int max;
> fd_set mset;
> @@ -2592,7 +2595,6 @@ void serveloop(GArray* servers) {
> handle_modern_connection(servers, sock);
> }
> for(i=0; i < servers->len; i++) {
> - int net;
> SERVER *serve;
>
> serve=&(g_array_index(servers, SERVER, i));
> @@ -2600,11 +2602,7 @@ void serveloop(GArray* servers) {
> continue;
> }
> if(FD_ISSET(serve->socket, &rset)) {
> - if ((net=accept(serve->socket, (struct sockaddr *) &addrin, &addrinlen)) < 0) {
> - err_nonfatal("accept: %m");
> - continue;
> - }
> - handle_oldstyle_connection(servers, net, serve);
> + handle_oldstyle_connection(servers, serve->socket, serve);
> }
> }
> }
>
--
This end should point toward the ground if you want to go to space.
If it starts pointing toward space you are having a bad problem and you
will not go to space today.
-- http://xkcd.com/1133/
Reply to: