added server.tag option

personal/stbuehler/wip
Thomas Porzelt 15 years ago
commit 3caab6a860

@ -31,16 +31,18 @@ network_status_t network_backend_writev(server *srv, connection *con, int fd, ch
gboolean did_write_something = FALSE;
chunkiter ci;
chunk *c;
network_status_t res = NETWORK_STATUS_FATAL_ERROR;
GArray *chunks = g_array_sized_new(FALSE, TRUE, sizeof(struct iovec), UIO_MAXIOV);
do {
if (0 == cq->length) return did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_FATAL_ERROR;
if (0 == cq->length) goto cleanup; /* FATAL ERROR */
do {
ci = chunkqueue_iter(cq);
if (MEM_CHUNK != (c = chunkiter_chunk(ci))->type) {
return did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_FATAL_ERROR;
res = did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_FATAL_ERROR;
goto cleanup;
}
we_have = 0;
@ -65,36 +67,45 @@ network_status_t network_backend_writev(server *srv, connection *con, int fd, ch
#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK
#endif
g_array_free(chunks, TRUE);
return did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_WAIT_FOR_EVENT;
res = did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_WAIT_FOR_EVENT;
goto cleanup;
case ECONNRESET:
case EPIPE:
g_array_free(chunks, TRUE);
return NETWORK_STATUS_CONNECTION_CLOSE;
res = NETWORK_STATUS_CONNECTION_CLOSE;
goto cleanup;
case EINTR:
break; /* try again */
default:
g_array_free(chunks, TRUE);
CON_ERROR(srv, con, "oops, write to fd=%d failed: %s", fd, g_strerror(errno));
return NETWORK_STATUS_FATAL_ERROR;
goto cleanup;
}
}
if (0 == r) {
g_array_free(chunks, TRUE);
return did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_WAIT_FOR_EVENT;
res = did_write_something ? NETWORK_STATUS_SUCCESS : NETWORK_STATUS_WAIT_FOR_EVENT;
goto cleanup;
}
chunkqueue_skip(cq, r);
*write_max -= r;
if (r != we_have) {
g_array_free(chunks, TRUE);
return NETWORK_STATUS_SUCCESS;
res = NETWORK_STATUS_SUCCESS;
goto cleanup;
}
if (0 == cq->length) {
res = NETWORK_STATUS_SUCCESS;
goto cleanup;
}
did_write_something = TRUE;
g_array_set_size(chunks, 0);
} while (*write_max > 0);
res = NETWORK_STATUS_SUCCESS;
cleanup:
g_array_free(chunks, TRUE);
return NETWORK_STATUS_SUCCESS;
return res;
}
network_status_t network_write_writev(server *srv, connection *con, int fd, chunkqueue *cq) {

@ -362,6 +362,8 @@ static const plugin_option options[] = {
{ "log.level", OPTION_STRING, core_option_log_level_parse, core_option_log_level_free },
{ "static-file.exclude", OPTION_LIST, NULL, NULL },
{ "server.tag", OPTION_STRING, NULL, NULL },
{ NULL, 0, NULL, NULL }
};

@ -7,7 +7,9 @@ enum core_options_t {
CORE_OPTION_LOG_TARGET = 1,
CORE_OPTION_LOG_LEVEL = 2,
CORE_OPTION_STATIC_FILE_EXCLUDE = 3
CORE_OPTION_STATIC_FILE_EXCLUDE = 3,
CORE_OPTION_SERVER_TAG = 4
};
/* the core plugin always has base index 0, as it is the first plugin loaded */

@ -1,6 +1,7 @@
#include "base.h"
#include "utils.h"
#include "plugin_core.h"
void response_init(response *resp) {
resp->headers = http_headers_new();
@ -112,10 +113,18 @@ void response_send_headers(server *srv, connection *con) {
}
if (!have_server) {
/* TODO: use option for this */
g_string_append_len(head, CONST_STR_LEN("Server: "));
g_string_append_len(head, CONST_STR_LEN("lighttpd-2.0~sandbox"));
g_string_append_len(head, CONST_STR_LEN("\r\n"));
GString *tag = CORE_OPTION(CORE_OPTION_SERVER_TAG);
if (!tag || tag->len) {
g_string_append_len(head, CONST_STR_LEN("Server: "));
if (tag)
g_string_append_len(head, GSTR_LEN(tag));
else
g_string_append_len(head, CONST_STR_LEN("lighttpd-2.0~sandbox"));
g_string_append_len(head, CONST_STR_LEN("\r\n"));
}
}
}

Loading…
Cancel
Save