server_socket minor change
Dustin Sallings
dustin at spy.net
Thu Feb 28 06:54:01 UTC 2008
Er, I don't know why I didn't just do this:
- 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;
On Feb 27, 2008, at 19:50, Dustin Sallings wrote:
>
> Hey, there's a change I've made a couple times in the binary tree,
> but I figure merges might be easier if we keep this straight.
>
> The basic idea here is to maintain the list as the pointer to
> listen_conn and build it backwards because there will be more than
> one invocation of server_socket for bringing up TCP listeners and
> the second one needs to not override the first.
>
> Anyone see anything obviously wrong with this?
>
> Note that it's net negative because I made it have a single return
> at the bottom. That's sort of a taste thing for me. I can take it
> out or clarify it if necessary.
>
> ---
> server/memcached.c | 12 ++++--------
> 1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/server/memcached.c b/server/memcached.c
> index 64ec08a..a36ffdb 100644
> --- a/server/memcached.c
> +++ b/server/memcached.c
> @@ -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};
> @@ -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) {
> @@ -2484,19 +2482,17 @@ static int server_socket(const int port,
> const bool is_udp) {
> }
>
> if (listen_conn == NULL) {
> - conn_ptr = listen_conn = listen_conn_add;
> + listen_conn = listen_conn_add;
> } else {
> - conn_ptr->next= listen_conn_add;
> + listen_conn_add->next = listen_conn->next;
> + listen_conn->next = listen_conn_add;
> }
> }
> }
>
> freeaddrinfo(ai);
>
> - if (success == 0)
> - return 1;
> -
> - return 0;
> + return success == 0;
> }
>
> static int new_socket_unix(void) {
> --
> 1.5.4.GIT
>
>
> --
> Dustin Sallings
>
>
--
Dustin Sallings
More information about the memcached
mailing list