Skip to content

Commit

Permalink
Minor refactoring of server_socket.
Browse files Browse the repository at this point in the history
Build the linked list out backwards so this command may be executed
more than once.  This also reduces the code a bit.


git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@729 b0b603af-a30f-0410-a34e-baf09ae79d0b
  • Loading branch information
dsallings committed Feb 29, 2008
1 parent b85c6c7 commit 6147ed7
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions memcached.c
Expand Up @@ -2390,7 +2390,6 @@ static void maximize_sndbuf(const int sfd) {
fprintf(stderr, "<%d send buffer was %d, now %d\n", sfd, old_size, last_good);
}


static int server_socket(const int port, const bool is_udp) {
int sfd;
struct linger ling = {0, 0};
Expand Down Expand Up @@ -2431,7 +2430,6 @@ static int server_socket(const int port, const bool is_udp) {
return 1;
}

conn *conn_ptr = NULL;
for (next= ai; next; next= next->ai_next) {
conn *listen_conn_add;
if ((sfd = new_socket(next)) == -1) {
Expand Down Expand Up @@ -2483,20 +2481,15 @@ static int server_socket(const int port, const bool is_udp) {
exit(EXIT_FAILURE);
}

if (listen_conn == NULL) {
conn_ptr = listen_conn = listen_conn_add;
} else {
conn_ptr->next= listen_conn_add;
}
listen_conn_add->next = listen_conn;
listen_conn = listen_conn_add;
}
}

freeaddrinfo(ai);

if (success == 0)
return 1;

return 0;
/* Return zero iff we detected no errors in starting up connections */
return success == 0;
}

static int new_socket_unix(void) {
Expand Down

0 comments on commit 6147ed7

Please sign in to comment.