X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=http_send.c;h=9a55ba0ecb1f540d93d12442e693cf642f8aa5c0;hp=40f0c0af2ee5995e7901c9aeffdb38feeb2f14fe;hb=5b8e525dfb2f18a4e0d67b9da264259159ad2184;hpb=62e9f05c8a2ae669e3efa1f92f6ae5cebde9878d diff --git a/http_send.c b/http_send.c index 40f0c0af..9a55ba0e 100644 --- a/http_send.c +++ b/http_send.c @@ -98,16 +98,14 @@ static void http_send(long unsigned current_chunk, static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds) { - int ret, i = -1, match; + int ret, fd; struct sender_client *sc, *tmp; struct private_http_sender_data *phsd; if (listen_fd < 0) return; list_for_each_entry_safe(sc, tmp, &clients, node) { - i++; phsd = sc->private_data; -// PARA_DEBUG_LOG("handling client %d: %s\n", i, remote_name(sc->fd)); switch (phsd->status) { case HTTP_STREAMING: /* nothing to do */ break; @@ -136,41 +134,39 @@ static void http_post_select(fd_set *rfds, __a_unused fd_set *wfds) if (!FD_ISSET(listen_fd, rfds)) return; ret = para_accept(listen_fd, NULL, 0); - if (ret < 0) - goto err_out; - sc = para_calloc(sizeof(*sc)); - sc->fd = ret; - sc->name = make_message("%s", remote_name(sc->fd)); - PARA_NOTICE_LOG("connection from %s (fd %d)\n", sc->name, sc->fd); + if (ret < 0) { + PARA_ERROR_LOG("%s\n", para_strerror(-ret)); + return; + } + fd = ret; ret = -E_MAX_CLIENTS; if (conf.http_max_clients_arg > 0 && numclients >= conf.http_max_clients_arg) { goto err_out; } - match = acl_lookup(sc->fd, &http_acl); - PARA_DEBUG_LOG("acl lookup returned %d\n", match); - ret = -E_ACL_PERM; - if ((match && !conf.http_default_deny_given) || - (!match && conf.http_default_deny_given)) + ret = mark_fd_nonblocking(fd); + if (ret < 0) goto err_out; - ret = mark_fd_nonblocking(sc->fd); + ret = acl_check_access(fd, &http_acl, conf.http_default_deny_given); if (ret < 0) goto err_out; + numclients++; + sc = para_calloc(sizeof(*sc)); + sc->fd = fd; + sc->name = make_message("%s", remote_name(fd)); + PARA_NOTICE_LOG("connection from %s (fd %d)\n", sc->name, fd); phsd = para_malloc(sizeof(*phsd)); sc->private_data = phsd; phsd->status = HTTP_CONNECTED; sc->cq = cq_new(MAX_BACKLOG); - numclients++; PARA_INFO_LOG("accepted client #%d: %s (fd %d)\n", numclients, - sc->name, sc->fd); + sc->name, fd); para_list_add(&sc->node, &clients); - add_close_on_fork_list(sc->fd); + add_close_on_fork_list(fd); return; err_out: PARA_WARNING_LOG("%s\n", para_strerror(-ret)); - if (sc->fd > 0) - close(sc->fd); - free(sc); + close(fd); } static void http_pre_select(int *max_fileno, fd_set *rfds, __a_unused fd_set *wfds) @@ -208,19 +204,15 @@ static int http_com_off(__a_unused struct sender_command_data *scd) static int http_com_deny(struct sender_command_data *scd) { - if (conf.http_default_deny_given) - acl_del_entry(&http_acl, scd->addr, scd->netmask); - else - acl_add_entry(&http_acl, scd->addr, scd->netmask); + acl_deny(scd->addr, scd->netmask, &http_acl, + conf.http_default_deny_given); return 1; } static int http_com_allow(struct sender_command_data *scd) { - if (conf.http_default_deny_given) - acl_add_entry(&http_acl, scd->addr, scd->netmask); - else - acl_del_entry(&http_acl, scd->addr, scd->netmask); + acl_allow(scd->addr, scd->netmask, &http_acl, + conf.http_default_deny_given); return 1; }