fix bugs and warnings from compiler warnings (memset parameter order, shadow, ...)

personal/stbuehler/wip
Stefan Bühler 10 years ago
parent 0ff0df8e12
commit 709296d796

@ -88,7 +88,7 @@ LI_API void li_action_acquire(liAction *a);
LI_API liAction *li_action_new_setting(liOptionSet setting);
LI_API liAction *li_action_new_settingptr(liOptionPtrSet setting);
LI_API liAction *li_action_new_function(liActionFuncCB func, liActionCleanupCB fcleanup, liActionFreeCB ffree, gpointer param);
LI_API liAction *li_action_new_list();
LI_API liAction *li_action_new_list(void);
LI_API liAction *li_action_new_condition(liCondition *cond, liAction *target, liAction *target_else);
LI_API liAction *li_action_new_balancer(liBackendSelectCB bselect, liBackendFallbackCB bfallback, liBackendFinishedCB bfinished, liBalancerFreeCB bfree, gpointer param, gboolean provide_backlog);

@ -3,7 +3,7 @@
/* error handling */
#define LI_ANGEL_CONFIG_PARSER_ERROR li_angel_config_parser_error_quark()
LI_API GQuark li_angel_config_parser_error_quark();
LI_API GQuark li_angel_config_parser_error_quark(void);
typedef enum {
LI_ANGEL_CONFIG_PARSER_ERROR_PARSE, /* parse error */

@ -66,10 +66,10 @@ struct liAngelCall {
/* error handling */
#define LI_ANGEL_CALL_ERROR li_angel_call_error_quark()
LI_API GQuark li_angel_call_error_quark();
LI_API GQuark li_angel_call_error_quark(void);
#define LI_ANGEL_CONNECTION_ERROR li_angel_connection_error_quark()
LI_API GQuark li_angel_connection_error_quark();
LI_API GQuark li_angel_connection_error_quark(void);
typedef enum {
LI_ANGEL_CALL_ALREADY_RUNNING, /* the angel_call struct is already in use for a call */
@ -120,7 +120,7 @@ LI_API void li_angel_cleanup_tables(liAngelConnection *acon);
/* Usage */
#if 0
void init() {
void init(void) {
/* ... init ctx... */
angel_call_init(&ctx->call);
ctx->call.context = ctx;
@ -168,7 +168,7 @@ done:
unlock();
}
void stop_call() {
void stop_call(void) {
lock();
ctx = get_ctx();
if (!angel_cancel_call(acon, ctx)) {

@ -28,7 +28,7 @@ struct liAngelBuffer {
/* error handling */
#define LI_ANGEL_DATA_ERROR li_angel_data_error_quark()
LI_API GQuark li_angel_data_error_quark();
LI_API GQuark li_angel_data_error_quark(void);
typedef enum {
LI_ANGEL_DATA_ERROR_EOF, /* not enough data to read value */

@ -40,13 +40,13 @@ struct liValue {
} data;
};
LI_API liValue* li_value_new_none();
LI_API liValue* li_value_new_none(void);
LI_API liValue* li_value_new_bool(gboolean val);
LI_API liValue* li_value_new_number(gint64 val);
LI_API liValue* li_value_new_string(GString *val);
LI_API liValue* li_value_new_range(liValueRange val);
LI_API liValue* li_value_new_list();
LI_API liValue* li_value_new_hash();
LI_API liValue* li_value_new_list(void);
LI_API liValue* li_value_new_hash(void);
LI_API liValue* li_value_copy(liValue* val);
LI_API void li_value_free(liValue* val);

@ -125,7 +125,7 @@ INLINE goffset li_chunk_length(liChunk *c);
* cqlimit *
******************/
LI_API liCQLimit* li_cqlimit_new();
LI_API liCQLimit* li_cqlimit_new(void);
LI_API void li_cqlimit_reset(liCQLimit *cql);
LI_API void li_cqlimit_acquire(liCQLimit *cql);
LI_API void li_cqlimit_release(liCQLimit *cql);
@ -135,7 +135,7 @@ LI_API void li_cqlimit_set_limit(liCQLimit *cql, goffset limit);
* chunkqueue *
******************/
LI_API liChunkQueue* li_chunkqueue_new();
LI_API liChunkQueue* li_chunkqueue_new(void);
LI_API void li_chunkqueue_reset(liChunkQueue *cq);
LI_API void li_chunkqueue_free(liChunkQueue *cq);

@ -120,7 +120,7 @@ LI_API void li_event_loop_force_close_sockets(liEventLoop *loop);
LI_API const char* li_event_loop_backend_string(liEventLoop *loop);
INLINE li_tstamp li_event_time();
INLINE li_tstamp li_event_time(void);
INLINE li_tstamp li_event_now(liEventLoop *loop);
LI_API void li_event_add_closing_socket(liEventLoop *loop, int fd);
@ -196,7 +196,7 @@ INLINE li_tstamp li_event_now(liEventLoop *loop) {
return ev_now(loop->loop);
}
INLINE li_tstamp li_event_time() {
INLINE li_tstamp li_event_time(void) {
return ev_time();
}
@ -511,8 +511,8 @@ INLINE liEventChild* li_event_child_from(liEventBase *base) {
return LI_CONTAINER_OF(base, liEventChild, base);
}
INLINE int li_event_signal_signum(liEventSignal *signal) {
return signal->libevmess.sig.signum;
INLINE int li_event_signal_signum(liEventSignal *sig) {
return sig->libevmess.sig.signum;
}
INLINE liEventSignal* li_event_signal_from(liEventBase *base) {

@ -25,7 +25,7 @@ struct liHttpHeaders {
/* strings always get copied, so you should free key and value yourself */
LI_API liHttpHeaders* li_http_headers_new();
LI_API liHttpHeaders* li_http_headers_new(void);
LI_API void li_http_headers_reset(liHttpHeaders* headers);
LI_API void li_http_headers_free(liHttpHeaders* headers);

@ -33,7 +33,7 @@ struct liMemcachedRequest {
/* error handling */
#define LI_MEMCACHED_ERROR li_memcached_error_quark()
LI_API GQuark li_memcached_error_quark();
LI_API GQuark li_memcached_error_quark(void);
typedef enum {
LI_MEMCACHED_CONNECTION,

@ -15,6 +15,6 @@ LI_API liMempoolPtr li_mempool_alloc(gsize size);
/* you cannot release parts from an allocated chunk; so you _have_ to remember the size from the alloc */
LI_API void li_mempool_free(liMempoolPtr ptr, gsize size);
LI_API void li_mempool_cleanup();
LI_API void li_mempool_cleanup(void);
#endif

@ -18,7 +18,7 @@ struct liProfilerMem {
};
LI_API void li_profiler_enable(gchar *output_path); /* enables the profiler */
LI_API void li_profiler_finish();
LI_API void li_profiler_finish(void);
LI_API void li_profiler_dump(gint minsize); /* dumps memory statistics to file specified in LI_PROFILE_MEM env var */
LI_API void li_profiler_hashtable_insert(const gpointer addr, gsize size); /* registers an allocated block with the profiler */
LI_API void li_profiler_hashtable_remove(const gpointer addr); /* unregisters an allocated block with the profiler */

@ -128,7 +128,7 @@ LI_API liServerSocket* li_server_listen(liServer *srv, int fd);
/* exit asap with cleanup */
LI_API void li_server_exit(liServer *srv);
LI_API GString *li_server_current_timestamp();
LI_API GString *li_server_current_timestamp(void);
LI_API void li_server_out_of_fds(liServer *srv);

@ -7,7 +7,7 @@
typedef void (*liThrottleNotifyCB)(liThrottleState *state, gpointer data);
LI_API liThrottleState* li_throttle_new();
LI_API liThrottleState* li_throttle_new(void);
LI_API void li_throttle_set(liWorker *wrk, liThrottleState *state, guint rate, guint burst);
LI_API void li_throttle_free(liWorker *wrk, liThrottleState *state);

@ -118,7 +118,7 @@ LI_API const char *li_remove_path(const char *path);
#endif
#define LI_SYS_ERROR li_sys_error_quark()
LI_API GQuark li_sys_error_quark();
LI_API GQuark li_sys_error_quark(void);
#define LI_SET_SYS_ERROR(error, msg) \
_li_set_sys_error(error, msg, REMOVE_PATH(__FILE__), __LINE__);

@ -26,12 +26,12 @@ struct liValue {
} data;
};
LI_API liValue* li_value_new_none();
LI_API liValue* li_value_new_none(void);
LI_API liValue* li_value_new_bool(gboolean val);
LI_API liValue* li_value_new_number(gint64 val);
LI_API liValue* li_value_new_string(GString *val);
LI_API liValue* li_value_new_list();
LI_API liValue* li_value_new_hash();
LI_API liValue* li_value_new_list(void);
LI_API liValue* li_value_new_hash(void);
LI_API liValue* li_value_new_action(liServer *srv, liAction *a);
LI_API liValue* li_value_new_condition(liServer *srv, liCondition *c);

@ -323,9 +323,9 @@ TARGET_LINK_LIBRARIES(lighttpd2 lighttpd-${PACKAGE_VERSION}-common lighttpd-${PA
SET(L_INSTALL_TARGETS ${L_INSTALL_TARGETS} lighttpd2-worker lighttpd2 lighttpd-${PACKAGE_VERSION}-common lighttpd-${PACKAGE_VERSION}-shared lighttpd-${PACKAGE_VERSION}-sharedangel)
IF(BUILD_EXTRA_WARNINGS)
SET(WARN_CFLAGS " -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith")
SET(WARN_CFLAGS " -g -O2 -g2 -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-align -Wsign-compare -Wnested-externs -Wpointer-arith -Wmissing-prototypes -Wshadow")
SET(WARN_LDFLAGS " -g -O2 -g2 -Wall -Wl,--as-needed")
# -Werror -Wbad-function-cast -Wmissing-prototypes
# -Werror
ELSE(BUILD_EXTRA_WARNINGS)
SET(WARN_CFLAGS "")
SET(WARN_LDFLAGS "")

@ -34,7 +34,7 @@ void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar
GString *log_ts = srv->log.ts_cache;
time_t li_cur_ts;
li_cur_ts = (time_t)li_event_now(&srv->loop);
li_cur_ts = (time_t) (li_event_now(&srv->loop));
if (li_cur_ts != srv->log.last_ts) {
gsize s;

@ -11,7 +11,7 @@
# ifndef HAVE_ISSETUGID
static int l_issetugid() {
static int l_issetugid(void) {
return (geteuid() != getuid() || getegid() != getgid());
}

@ -1,6 +1,6 @@
#include <lighttpd/angel_base.h>
liValue* li_value_new_none() {
liValue* li_value_new_none(void) {
liValue *v = g_slice_new0(liValue);
v->type = LI_VALUE_NONE;
return v;
@ -34,7 +34,7 @@ liValue* li_value_new_range(liValueRange val) {
return v;
}
liValue* li_value_new_list() {
liValue* li_value_new_list(void) {
liValue *v = g_slice_new0(liValue);
v->data.list = g_ptr_array_new();
v->type = LI_VALUE_LIST;
@ -49,7 +49,7 @@ static void _value_hash_free_value(gpointer data) {
li_value_free((liValue*) data);
}
liValue* li_value_new_hash() {
liValue* li_value_new_hash(void) {
liValue *v = g_slice_new0(liValue);
v->data.hash = g_hash_table_new_full(
(GHashFunc) g_string_hash, (GEqualFunc) g_string_equal,

@ -84,10 +84,10 @@ static void send_queue_clean(GQueue *queue) {
}
}
GQuark li_angel_call_error_quark() {
GQuark li_angel_call_error_quark(void) {
return g_quark_from_static_string("angel-call-error-quark");
}
GQuark li_angel_connection_error_quark() {
GQuark li_angel_connection_error_quark(void) {
return g_quark_from_static_string("angel-connection-error-quark");
}

@ -4,7 +4,7 @@
#include <lighttpd/utils.h>
/* error handling */
GQuark li_angel_data_error_quark() {
GQuark li_angel_data_error_quark(void) {
return g_quark_from_static_string("angel-data-error-quark");
}

@ -7,7 +7,7 @@ typedef struct closing_socket closing_socket;
struct closing_socket {
liEventLoop *loop;
GList link;
GList sockets_link;
int fd;
li_tstamp close_timeout;
};
@ -15,7 +15,7 @@ struct closing_socket {
static void close_socket_now(closing_socket *cs) {
close(cs->fd);
cs->fd = -1;
g_queue_unlink(&cs->loop->closing_sockets, &cs->link);
g_queue_unlink(&cs->loop->closing_sockets, &cs->sockets_link);
}
static void closing_socket_cb(int revents, void* arg) {
@ -78,7 +78,7 @@ void li_event_add_closing_socket(liEventLoop *loop, int fd) {
cs = g_slice_new0(closing_socket);
cs->loop = loop;
cs->fd = fd;
g_queue_push_tail_link(&loop->closing_sockets, &cs->link);
g_queue_push_tail_link(&loop->closing_sockets, &cs->sockets_link);
cs->close_timeout = li_event_now(loop) + 10.0;
ev_once(loop->loop, fd, EV_READ, 10.0, closing_socket_cb, cs);
@ -96,23 +96,23 @@ void li_event_loop_init(liEventLoop *loop, struct ev_loop *evloop) {
struct ev_loop* li_event_loop_clear(liEventLoop *loop) {
struct ev_loop* evloop = loop->loop;
GList *link;
GList *lnk;
li_event_loop_end(loop);
li_job_queue_clear(&loop->jobqueue);
while (NULL != (link = loop->watchers.head)) {
liEventBase *base = LI_CONTAINER_OF(link, liEventBase, link_watchers);
while (NULL != (lnk = loop->watchers.head)) {
liEventBase *base = LI_CONTAINER_OF(lnk, liEventBase, link_watchers);
assert(li_event_attached_(base));
li_event_detach_(base);
assert(link != loop->watchers.head);
assert(lnk != loop->watchers.head);
}
loop->loop = NULL;
return evloop;
}
void li_event_loop_run(liEventLoop *loop) {
ev_run(loop->loop, 0);
ev_loop(loop->loop, 0);
}
void li_event_loop_end(liEventLoop *loop) {
@ -129,10 +129,10 @@ void li_event_loop_exit(liEventLoop *loop) {
}
void li_event_loop_force_close_sockets(liEventLoop *loop) {
GList *link;
GList *lnk;
while (NULL != (link = loop->closing_sockets.head)) {
closing_socket *cs = LI_CONTAINER_OF(link, closing_socket, link);
while (NULL != (lnk = loop->closing_sockets.head)) {
closing_socket *cs = LI_CONTAINER_OF(lnk, closing_socket, sockets_link);
ev_feed_fd_event(loop->loop, cs->fd, EV_READ);
close_socket_now(cs);
}
@ -172,7 +172,7 @@ static int io_events_to_libev(int events) {
}
void li_event_io_init(liEventLoop *loop, liEventIO *io, liEventCallback callback, int fd, int events) {
memset(io, sizeof(io), 0);
memset(io, 0, sizeof(io));
io->base.type = LI_EVT_IO;
io->base.keep_loop_alive = 1;
io->base.callback = callback;
@ -252,7 +252,7 @@ static void event_timer_cb(struct ev_loop *loop, ev_timer *w, int revents) {
}
void li_event_timer_init(liEventLoop *loop, liEventTimer *timer, liEventCallback callback) {
memset(timer, sizeof(timer), 0);
memset(timer, 0, sizeof(timer));
timer->base.type = LI_EVT_TIMER;
timer->base.keep_loop_alive = 1;
timer->base.callback = callback;
@ -274,7 +274,7 @@ static void event_async_cb(struct ev_loop *loop, ev_async *w, int revents) {
}
void li_event_async_init(liEventLoop *loop, liEventAsync *async, liEventCallback callback) {
memset(async, sizeof(async), 0);
memset(async, 0, sizeof(async));
async->base.type = LI_EVT_ASYNC;
async->base.keep_loop_alive = 0;
async->base.callback = callback;
@ -303,7 +303,7 @@ static void event_child_cb(struct ev_loop *loop, ev_child *w, int revents) {
}
void li_event_child_init(liEventLoop *loop, liEventChild *child, liEventCallback callback, int pid) {
memset(child, sizeof(child), 0);
memset(child, 0, sizeof(child));
child->base.type = LI_EVT_CHILD;
child->base.keep_loop_alive = 1;
child->base.callback = callback;
@ -327,7 +327,7 @@ static void event_signal_cb(struct ev_loop *loop, ev_signal *w, int revents) {
}
void li_event_signal_init(liEventLoop *loop, liEventSignal *sig, liEventCallback callback, int signum) {
memset(sig, sizeof(sig), 0);
memset(sig, 0, sizeof(sig));
sig->base.type = LI_EVT_SIGNAL;
sig->base.keep_loop_alive = 0;
sig->base.callback = callback;
@ -351,7 +351,7 @@ static void event_prepare_cb(struct ev_loop *loop, ev_prepare *w, int revents) {
}
void li_event_prepare_init(liEventLoop *loop, liEventPrepare *prepare, liEventCallback callback) {
memset(prepare, sizeof(prepare), 0);
memset(prepare, 0, sizeof(prepare));
prepare->base.type = LI_EVT_PREPARE;
prepare->base.keep_loop_alive = 0;
prepare->base.callback = callback;
@ -374,7 +374,7 @@ static void event_check_cb(struct ev_loop *loop, ev_check *w, int revents) {
}
void li_event_check_init(liEventLoop *loop, liEventCheck *check, liEventCallback callback) {
memset(check, sizeof(check), 0);
memset(check, 0, sizeof(check));
check->base.type = LI_EVT_CHECK;
check->base.keep_loop_alive = 0;
check->base.callback = callback;

@ -21,7 +21,7 @@
* before we drop all requests
*/
GQuark li_memcached_error_quark() {
GQuark li_memcached_error_quark(void) {
return g_quark_from_static_string("memcached-error-quark");
}

@ -33,7 +33,7 @@ void li_mempool_free(liMempoolPtr ptr, gsize size) {
g_free(ptr.data);
}
void li_mempool_cleanup() {
void li_mempool_cleanup(void) {
}
gsize li_mempool_align_page_size(gsize size) {
@ -134,7 +134,7 @@ static gsize mp_pagesize = 0;
static GStaticMutex mp_init_mutex = G_STATIC_MUTEX_INIT;
static void mempool_init() {
static void mempool_init(void) {
g_static_mutex_lock (&mp_init_mutex);
if (!mp_initialized) {
mp_pagesize = sysconf(_SC_PAGE_SIZE);
@ -481,7 +481,7 @@ void li_mempool_free(liMempoolPtr ptr, gsize size) {
mp_mag_release(mag); /* keep track of chunk count; release always after unlock! */
}
void li_mempool_cleanup() {
void li_mempool_cleanup(void) {
/* "Force" thread-private cleanup */
mp_pools *pools;

@ -58,7 +58,7 @@ static guint profiler_hash(gpointer addr) {
return ((uintptr_t)addr * 2654435761); /* ~ golden ratio of 2^32 */
}
static profiler_block *profiler_block_new() {
static profiler_block *profiler_block_new(void) {
profiler_block *block;
if (!block_free_list) {
@ -284,7 +284,7 @@ void li_profiler_enable(gchar *output_path) {
li_profiler_enabled = TRUE;
}
void li_profiler_finish() {
void li_profiler_finish(void) {
guint i;
profiler_block *block, *block_tmp;

@ -821,7 +821,7 @@ const char *li_remove_path(const char *path) {
return path;
}
GQuark li_sys_error_quark() {
GQuark li_sys_error_quark(void) {
return g_quark_from_static_string("li-sys-error-quark");
}

@ -88,7 +88,7 @@ liAction *li_action_new_function(liActionFuncCB func, liActionCleanupCB fcleanup
return a;
}
liAction *li_action_new_list() {
liAction *li_action_new_list(void) {
liAction *a;
a = g_slice_new(liAction);

@ -15,7 +15,7 @@ struct liBackendWait {
*/
liBackendConnection_p *con;
GList link; /* link in wait_queue (either pool or wpool) */
GList wait_queue_link; /* link in wait_queue (either pool or wpool) */
gboolean failed;
liVRequest *vr;
@ -264,7 +264,7 @@ static void S_backend_pool_failed(liBackendWorkerPool *wpool) {
}
while (NULL != (elem = g_queue_pop_head_link(&pool->wait_queue))) {
liBackendWait *bwait = LI_CONTAINER_OF(elem, liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(elem, liBackendWait, wait_queue_link);
bwait->failed = TRUE;
li_job_async(bwait->vr_ref);
}
@ -272,7 +272,7 @@ static void S_backend_pool_failed(liBackendWorkerPool *wpool) {
for (guint i = 0, len = wpool->wrk->srv->worker_count; i < len; ++i) {
liBackendWorkerPool *_wpool = &pool->worker_pools[i];
while (NULL != (elem = g_queue_pop_head_link(&_wpool->wait_queue))) {
liBackendWait *bwait = LI_CONTAINER_OF(elem, liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(elem, liBackendWait, wait_queue_link);
bwait->failed = TRUE;
li_job_async(bwait->vr_ref);
}
@ -440,7 +440,7 @@ static void S_backend_pool_distribute(liBackendPool_p *pool, liWorker *wrk) {
if (0 == wpool->wait_queue.length) return;
while (wpool->wait_queue.length > 0 && wpool->idle > 0) {
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&wpool->wait_queue), liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&wpool->wait_queue), liBackendWait, wait_queue_link);
liBackendConnection_p *con = g_ptr_array_index(wpool->connections, wpool->active + wpool->reserved);
bwait->con = con;
@ -481,9 +481,9 @@ static void S_backend_pool_distribute(liBackendPool_p *pool, liWorker *wrk) {
{
guint i;
for (i = use; i > 0; --i) {
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&pool->wait_queue), liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&pool->wait_queue), liBackendWait, wait_queue_link);
liBackendWorkerPool *wpool = &pool->worker_pools[bwait->vr->wrk->ndx];
g_queue_push_tail_link(&wpool->wait_queue, &bwait->link);
g_queue_push_tail_link(&wpool->wait_queue, &bwait->wait_queue_link);
}
}
@ -495,7 +495,7 @@ static void S_backend_pool_distribute(liBackendPool_p *pool, liWorker *wrk) {
ERROR(wrk->srv, "pool %i: queue: %i, idle: %i", i, wpool->wait_queue.length, wpool->idle);
while (wpool->wait_queue.length > 0 && wpool->idle > 0) {
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&wpool->wait_queue), liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&wpool->wait_queue), liBackendWait, wait_queue_link);
liBackendConnection_p *con = g_ptr_array_index(wpool->connections, wpool->active + wpool->reserved);
bwait->con = con;
@ -521,7 +521,7 @@ static void S_backend_pool_distribute(liBackendPool_p *pool, liWorker *wrk) {
liBackendWorkerPool *wpool = &pool->worker_pools[i];
while (wpool->wait_queue.length > 0) {
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&wpool->wait_queue), liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_pop_head_link(&wpool->wait_queue), liBackendWait, wait_queue_link);
liBackendConnection_p *con;
liBackendWorkerPool *srcpool;
@ -562,35 +562,35 @@ static void S_backend_pool_distribute(liBackendPool_p *pool, liWorker *wrk) {
}
}
static void S_backend_wait_queue_unshift(GQueue *queue, GList *link) {
static void S_backend_wait_queue_unshift(GQueue *queue, GList *lnk) {
if (0 == queue->length) {
g_queue_push_head_link(queue, link);
g_queue_push_head_link(queue, lnk);
} else {
liBackendWait *link_wait = LI_CONTAINER_OF(link, liBackendWait, link);
liBackendWait *link_wait = LI_CONTAINER_OF(lnk, liBackendWait, wait_queue_link);
GList *cursor = queue->head;
liBackendWait *wait = LI_CONTAINER_OF(cursor, liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(cursor, liBackendWait, wait_queue_link);
if (wait->ts_started > link_wait->ts_started) {
g_queue_push_head_link(queue, link);
if (bwait->ts_started > link_wait->ts_started) {
g_queue_push_head_link(queue, lnk);
return;
}
do {
cursor = cursor->next;
if (NULL == cursor) {
g_queue_push_tail_link(queue, link);
g_queue_push_tail_link(queue, lnk);
return;
}
wait = LI_CONTAINER_OF(cursor, liBackendWait, link);
} while (wait->ts_started < link_wait->ts_started);
bwait = LI_CONTAINER_OF(cursor, liBackendWait, wait_queue_link);
} while (bwait->ts_started < link_wait->ts_started);
/* insert link before cursor; link will neither be the first nor the last element,
/* insert lnk before cursor; lnk will neither be the first nor the last element,
* so we don't have to udpate queue->head/tail
*/
link->next = cursor;
link->prev = cursor->prev;
cursor->prev->next = link;
cursor->prev = link;
lnk->next = cursor;
lnk->prev = cursor->prev;
cursor->prev->next = lnk;
cursor->prev = lnk;
}
}
@ -604,9 +604,9 @@ static void backend_connection_close(liBackendPool_p *pool, liBackendConnection_
if (NULL != con->wait) {
con->wait->con = NULL;
if (pool->public.config->max_connections <= 0) {
S_backend_wait_queue_unshift(&wpool->wait_queue, &con->wait->link);
S_backend_wait_queue_unshift(&wpool->wait_queue, &con->wait->wait_queue_link);
} else {
S_backend_wait_queue_unshift(&pool->wait_queue, &con->wait->link);
S_backend_wait_queue_unshift(&pool->wait_queue, &con->wait->wait_queue_link);
}
S_backend_pool_distribute(pool, con->wait->vr->wrk);
con->wait = NULL;
@ -728,7 +728,7 @@ static void S_backend_pool_update_wait_queue_timer(liBackendWorkerPool *wpool) {
if (pool->wait_queue.length > 0) {
li_tstamp now = li_cur_ts(wpool->wrk);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_peek_head_link(&pool->wait_queue), liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_peek_head_link(&pool->wait_queue), liBackendWait, wait_queue_link);
li_tstamp repeat = bwait->ts_started + pool->public.config->wait_timeout - now;
if (repeat < 0.05) repeat = 0.05;
@ -750,7 +750,7 @@ static void backend_pool_wait_queue_timeout(liEventBase *watcher, int events) {
g_mutex_lock(pool->lock);
while (pool->wait_queue.length > 0) {
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_peek_head_link(&pool->wait_queue), liBackendWait, link);
liBackendWait *bwait = LI_CONTAINER_OF(g_queue_peek_head_link(&pool->wait_queue), liBackendWait, wait_queue_link);
if (bwait->ts_started <= due) {
g_queue_pop_head_link(&pool->wait_queue);
@ -953,9 +953,9 @@ liBackendResult li_backend_get(liVRequest *vr, liBackendPool *bpool, liBackendCo
*pbwait = bwait;
if (pool->public.config->max_connections <= 0) {
g_queue_push_tail_link(&wpool->wait_queue, &bwait->link);
g_queue_push_tail_link(&wpool->wait_queue, &bwait->wait_queue_link);
} else {
g_queue_push_tail_link(&pool->wait_queue, &bwait->link);
g_queue_push_tail_link(&pool->wait_queue, &bwait->wait_queue_link);
S_backend_pool_update_wait_queue_timer(wpool);
}
S_backend_pool_distribute(pool, vr->wrk);
@ -1038,9 +1038,9 @@ void li_backend_wait_stop(liVRequest *vr, liBackendPool *bpool, liBackendWait **
bwait->con = NULL;
} else if (pool->public.config->max_connections <= 0) {
liBackendWorkerPool *wpool = &pool->worker_pools[bwait->vr->wrk->ndx];
g_queue_unlink(&wpool->wait_queue, &bwait->link);
g_queue_unlink(&wpool->wait_queue, &bwait->wait_queue_link);
} else {
g_queue_unlink(&pool->wait_queue, &bwait->link);
g_queue_unlink(&pool->wait_queue, &bwait->wait_queue_link);
}
}

@ -275,7 +275,7 @@ read_chunk:
* chunk *
******************/
static liChunk* chunk_new() {
static liChunk* chunk_new(void) {
liChunk *c = g_slice_new0(liChunk);
c->data.file.mmap.data = MAP_FAILED;
c->cq_link.data = c;
@ -322,7 +322,7 @@ static void chunk_free(liChunkQueue *cq, liChunk *c) {
/******************
* cqlimit *
******************/
liCQLimit* li_cqlimit_new() {
liCQLimit* li_cqlimit_new(void) {
liCQLimit *cql = g_slice_new0(liCQLimit);
cql->refcount = 1;
cql->limit = -1;
@ -416,7 +416,7 @@ void li_cqlimit_set_limit(liCQLimit *cql, goffset limit) {
* chunkqueue *
******************/
liChunkQueue* li_chunkqueue_new() {
liChunkQueue* li_chunkqueue_new(void) {
liChunkQueue *cq = g_slice_new0(liChunkQueue);
g_queue_init(&cq->queue);
return cq;

@ -117,14 +117,14 @@ static void simple_tcp_finished(liConnection *con, gboolean aborted) {
static liThrottleState* simple_tcp_throttle_out(liConnection *con) {
simple_tcp_connection *data = con->con_sock.data;
if (NULL == data) return NULL;
if (NULL == data->sock_stream->throttle_out) data->sock_stream->throttle_out = li_throttle_new(con->wrk);
if (NULL == data->sock_stream->throttle_out) data->sock_stream->throttle_out = li_throttle_new();
return data->sock_stream->throttle_out;
}
static liThrottleState* simple_tcp_throttle_in(liConnection *con) {
simple_tcp_connection *data = con->con_sock.data;
if (NULL == data) return NULL;
if (NULL == data->sock_stream->throttle_in) data->sock_stream->throttle_in = li_throttle_new(con->wrk);
if (NULL == data->sock_stream->throttle_in) data->sock_stream->throttle_in = li_throttle_new();
return data->sock_stream->throttle_in;
}

@ -27,7 +27,7 @@ static void _header_queue_free(gpointer data, gpointer userdata) {
_http_header_free((liHttpHeader*) data);
}
liHttpHeaders* li_http_headers_new() {
liHttpHeaders* li_http_headers_new(void) {
liHttpHeaders* headers = g_slice_new0(liHttpHeaders);
g_queue_init(&headers->entries);
return headers;

@ -557,7 +557,7 @@ void li_server_exit(liServer *srv) {
}
/* cache timestamp */
GString *li_server_current_timestamp() {
GString *li_server_current_timestamp(void) {
static GStaticPrivate last_ts_key = G_STATIC_PRIVATE_INIT;
static GStaticPrivate ts_str_key = G_STATIC_PRIVATE_INIT;

@ -5,7 +5,7 @@
#include <lighttpd/config_parser.h>
int request_test() {
int request_test(void) {
liChunkQueue *cq;
liRequest req;
liHandlerResult res;
@ -34,7 +34,7 @@ int request_test() {
return res == LI_HANDLER_GO_ON ? 0 : 1;
}
int main() {
int main(void) {
liServer *srv;
guint32 ip, netmask;

@ -292,7 +292,7 @@ void li_throttle_remove_pool(liWorker *wrk, liThrottleState *state, liThrottlePo
}
}
liThrottleState* li_throttle_new() {
liThrottleState* li_throttle_new(void) {
liThrottleState *state = g_slice_new0(liThrottleState);
state->pools = g_ptr_array_new();
return state;

@ -1,6 +1,6 @@
#include <lighttpd/base.h>
liValue* li_value_new_none() {
liValue* li_value_new_none(void) {
liValue *v = g_slice_new0(liValue);
v->type = LI_VALUE_NONE;
return v;
@ -27,7 +27,7 @@ liValue* li_value_new_string(GString *val) {
return v;
}
liValue* li_value_new_list() {
liValue* li_value_new_list(void) {
liValue *v = g_slice_new0(liValue);
v->data.list = g_array_new(FALSE, TRUE, sizeof(liValue*));
v->type = LI_VALUE_LIST;
@ -42,7 +42,7 @@ static void _value_hash_free_value(gpointer data) {
li_value_free((liValue*) data);
}
liValue* li_value_new_hash() {
liValue* li_value_new_hash(void) {
liValue *v = g_slice_new0(liValue);
v->data.hash = g_hash_table_new_full(
(GHashFunc) g_string_hash, (GEqualFunc) g_string_equal,

@ -211,14 +211,14 @@ static void gnutlc_tcp_finished(liConnection *con, gboolean aborted) {
static liThrottleState* gnutls_tcp_throttle_out(liConnection *con) {
mod_connection_ctx *conctx = con->con_sock.data;
if (NULL == conctx) return NULL;
if (NULL == conctx->sock_stream->throttle_out) conctx->sock_stream->throttle_out = li_throttle_new(con->wrk);
if (NULL == conctx->sock_stream->throttle_out) conctx->sock_stream->throttle_out = li_throttle_new();
return conctx->sock_stream->throttle_out;
}
static liThrottleState* gnutls_tcp_throttle_in(liConnection *con) {
mod_connection_ctx *conctx = con->con_sock.data;
if (NULL == conctx) return NULL;
if (NULL == conctx->sock_stream->throttle_in) conctx->sock_stream->throttle_in = li_throttle_new(con->wrk);
if (NULL == conctx->sock_stream->throttle_in) conctx->sock_stream->throttle_in = li_throttle_new();
return conctx->sock_stream->throttle_in;
}

@ -172,14 +172,14 @@ static void openssl_tcp_finished(liConnection *con, gboolean aborted) {
static liThrottleState* openssl_tcp_throttle_out(liConnection *con) {
openssl_connection_ctx *conctx = con->con_sock.data;
if (NULL == conctx) return NULL;
if (NULL == conctx->sock_stream->throttle_out) conctx->sock_stream->throttle_out = li_throttle_new(con->wrk);
if (NULL == conctx->sock_stream->throttle_out) conctx->sock_stream->throttle_out = li_throttle_new();
return conctx->sock_stream->throttle_out;
}
static liThrottleState* openssl_tcp_throttle_in(liConnection *con) {
openssl_connection_ctx *conctx = con->con_sock.data;
if (NULL == conctx) return NULL;
if (NULL == conctx->sock_stream->throttle_in) conctx->sock_stream->throttle_in = li_throttle_new(con->wrk);
if (NULL == conctx->sock_stream->throttle_in) conctx->sock_stream->throttle_in = li_throttle_new();
return conctx->sock_stream->throttle_in;
}
@ -690,7 +690,7 @@ static unsigned long ssl_id_cb(void) {
return (intptr_t) g_thread_self();
}
static void sslthread_init() {
static void sslthread_init(void) {
int n = CRYPTO_num_locks(), i;
ssl_locks = g_slice_alloc0(sizeof(GMutex*) * n);
@ -703,7 +703,7 @@ static void sslthread_init() {
CRYPTO_set_id_callback(ssl_id_cb);
}
static void sslthread_free() {
static void sslthread_free(void) {
int n = CRYPTO_num_locks(), i;
for (i = 0; i < n; i++) {

@ -3,6 +3,11 @@
#define perror(msg) g_error("(%s:%i) %s failed: %s", __FILE__, __LINE__, msg, g_strerror(errno))
static void force_write(int fd, const void *buf, size_t count) {
ssize_t r = write(fd, buf, count);
if (r < 0 || (size_t)r != count) perror("write");
}
static void test_send_fd(void) {
int pipefds[2], sockfd[2], rfd = -1;
char buf[5];
@ -21,7 +26,7 @@ static void test_send_fd(void) {
}
/* check whether we still can send normal data after fd */
write(sockfd[0], CONST_STR_LEN("abcx"));
force_write(sockfd[0], CONST_STR_LEN("abcx"));
/* check receiving fd */
if (-1 == li_receive_fd(sockfd[1], &rfd)) {
@ -40,7 +45,7 @@ static void test_send_fd(void) {
g_assert_cmpstr(buf, ==, "abcx");
/* check whether pipe still works after receiving end was passed */
write(pipefds[1], CONST_STR_LEN("test"));
force_write(pipefds[1], CONST_STR_LEN("test"));
buf[0] = '\0';
if (-1 == read(rfd, buf, 5)) {
@ -75,7 +80,7 @@ static void test_send_fd_with_fast_close(void) {
}
/* check whether we still can send normal data after fd */
write(sockfd[0], CONST_STR_LEN("abcx"));
force_write(sockfd[0], CONST_STR_LEN("abcx"));
/* make sure we can close the fd before the other end received it */
close(pipefds[0]);
@ -97,7 +102,7 @@ static void test_send_fd_with_fast_close(void) {
g_assert_cmpstr(buf, ==, "abcx");
/* check whether pipe still works after receiving end was passed */
write(pipefds[1], CONST_STR_LEN("test"));
force_write(pipefds[1], CONST_STR_LEN("test"));
buf[0] = '\0';
if (-1 == read(rfd, buf, 5)) {

Loading…
Cancel
Save