src/ebb.c in ebb-0.2.0 vs src/ebb.c in ebb-0.2.1

- old
+ new

@@ -40,31 +40,31 @@ { if(client->env_size >= EBB_MAX_ENV) { client->parser.overflow_error = TRUE; return; } - client->env[client->env_size].type = -1; - client->env[client->env_size].field = field; - client->env[client->env_size].field_length = flen; - client->env[client->env_size].value = value; - client->env[client->env_size].value_length = vlen; - client->env_size += 1; + struct ebb_env_item * const item = &client->env[client->env_size++]; + item->type = -1; + item->field_length = flen; + item->value_length = vlen; + item->field = field; + item->value = value; } void env_add_const(ebb_client *client, int type, const char *value, int vlen) { if(client->env_size >= EBB_MAX_ENV) { client->parser.overflow_error = TRUE; return; } - client->env[client->env_size].type = type; - client->env[client->env_size].field = NULL; - client->env[client->env_size].field_length = -1; - client->env[client->env_size].value = value; - client->env[client->env_size].value_length = vlen; - client->env_size += 1; + struct ebb_env_item * const item = &client->env[client->env_size++]; + item->type = type; + item->field_length = -1; + item->value_length = vlen; + item->field = NULL; + item->value = value; } void http_field_cb(void *data, const char *field, size_t flen, const char *value, size_t vlen) { @@ -224,11 +224,11 @@ /* If the client is already open, reuse the fd, just reset all the parameters * this would happen in the case of a keep_alive request */ if(!client->open) { /* DO SOCKET STUFF */ - socklen_t len; + socklen_t len = sizeof(struct sockaddr); int fd = accept(client->server->fd, (struct sockaddr*)&(client->sockaddr), &len); if(fd < 0) { perror("accept()"); return; } @@ -274,11 +274,11 @@ ev_init(&client->read_watcher, on_client_readable); ev_io_set(&client->read_watcher, client->fd, EV_READ | EV_ERROR); ev_io_start(client->server->loop, &client->read_watcher); client->timeout_watcher.data = client; - ev_timer_init(&client->timeout_watcher, on_timeout, EBB_TIMEOUT, EBB_TIMEOUT); + ev_timer_init(&client->timeout_watcher, on_timeout, EBB_TIMEOUT, 0); ev_timer_start(client->server->loop, &client->timeout_watcher); } static void on_request(struct ev_loop *loop, ev_io *watcher, int revents) @@ -297,10 +297,10 @@ * and set up her callbacks for read and write * the client won't get passed back to the user, however, * until the request is complete and parsed. */ int i; - ebb_client *client; + ebb_client *client = NULL; /* Get next availible peer */ for(i=0; i < EBB_MAX_CLIENTS; i++) if(!server->clients[i].in_use && !server->clients[i].open) { client = &(server->clients[i]); break;