From 9610ec72abb22649770c965939eeb9aad7bf0979 Mon Sep 17 00:00:00 2001 From: Unbit Date: Fri, 15 Feb 2013 22:24:03 +0100 Subject: [PATCH] openindiana fixes --- core/event.c | 17 ++++++- core/subscription.c | 84 +++++++++++++++++------------------ plugins/gevent/gevent.h | 2 +- plugins/http/https.c | 38 ++++++++-------- plugins/sslrouter/sslrouter.c | 30 ++++++------- uwsgi.h | 9 ++-- 6 files changed, 96 insertions(+), 84 deletions(-) diff --git a/core/event.c b/core/event.c index e80c7296..67607507 100644 --- a/core/event.c +++ b/core/event.c @@ -108,7 +108,7 @@ int event_queue_interesting_fd_has_error(void *events, int id) { int event_queue_interesting_fd_is_read(void *events, int id) { port_event_t *pe = (port_event_t *) events; - if (pe[id].portev_events = POLLIN) { + if (pe[id].portev_events == POLLIN) { return 1; } return 0; @@ -124,7 +124,7 @@ int event_queue_interesting_fd_is_write(void *events, int id) { int event_queue_add_fd_read(int eq, int fd) { - if (port_associate(eq, PORT_SOURCE_FD, fd, POLLIN, (void *) eq)) { + if (port_associate(eq, PORT_SOURCE_FD, fd, POLLIN, NULL)) { uwsgi_error("port_associate"); return -1; } @@ -171,6 +171,7 @@ int event_queue_wait_multi(int eq, int timeout, void *events, int nevents) { int ret; uint_t nget = 1; timespec_t ts; + if (timeout >= 0) { ts.tv_sec = timeout; @@ -189,6 +190,18 @@ int event_queue_wait_multi(int eq, int timeout, void *events, int nevents) { return 0; } + uint_t i; + port_event_t *pe = (port_event_t *) events; + for(i=0;iportev_source == PORT_SOURCE_FD) { + // event must be readded (damn Oracle/Sun why the fu*k you made such a horrible choice ???? why not adding a ONESHOT flag ???) + if (port_associate(eq, pe_i->portev_source, pe_i->portev_object, pe_i->portev_events, NULL)) { + uwsgi_error("port_associate"); + } + } + } + return nget; } diff --git a/core/subscription.c b/core/subscription.c index aa5d3865..ad7f1788 100644 --- a/core/subscription.c +++ b/core/subscription.c @@ -743,72 +743,72 @@ clear: void uwsgi_subscribe2(char *arg, uint8_t cmd) { - char *s_server = NULL; - char *s_key = NULL; - char *s_socket = NULL; - char *s_addr = NULL; - char *s_weight = NULL; - char *s_sign = NULL; - char *s_modifier1 = NULL; - char *s_modifier2 = NULL; - char *s_check = NULL; + char *s2_server = NULL; + char *s2_key = NULL; + char *s2_socket = NULL; + char *s2_addr = NULL; + char *s2_weight = NULL; + char *s2_sign = NULL; + char *s2_modifier1 = NULL; + char *s2_modifier2 = NULL; + char *s2_check = NULL; if (uwsgi_kvlist_parse(arg, strlen(arg), ',', '=', - "server", &s_server, - "key", &s_key, - "socket", &s_socket, - "addr", &s_addr, - "weight", &s_weight, - "modifier1", &s_modifier1, - "modifier2", &s_modifier2, - "sign", &s_sign, - "check", &s_check, + "server", &s2_server, + "key", &s2_key, + "socket", &s2_socket, + "addr", &s2_addr, + "weight", &s2_weight, + "modifier1", &s2_modifier1, + "modifier2", &s2_modifier2, + "sign", &s2_sign, + "check", &s2_check, NULL)) { return; } - if (!s_server && !s_key) goto end; + if (!s2_server && !s2_key) goto end; - if (s_check) { - if (uwsgi_file_exists(s_check)) goto end; + if (s2_check) { + if (uwsgi_file_exists(s2_check)) goto end; } - if (s_weight) { - uwsgi.weight = atoi(s_weight); + if (s2_weight) { + uwsgi.weight = atoi(s2_weight); } - if (s_socket) { - struct uwsgi_socket *us = uwsgi_get_socket_by_num(atoi(s_socket)); + if (s2_socket) { + struct uwsgi_socket *us = uwsgi_get_socket_by_num(atoi(s2_socket)); if (us) { - if (s_addr) { - free(s_addr); + if (s2_addr) { + free(s2_addr); } - s_addr = uwsgi_str(us->name); + s2_addr = uwsgi_str(us->name); } } uint8_t modifier1 = 0; uint8_t modifier2 = 0; - if (s_modifier1) { - modifier1 = atoi(s_modifier1); + if (s2_modifier1) { + modifier1 = atoi(s2_modifier1); } - if (s_modifier2) { - modifier2 = atoi(s_modifier2); + if (s2_modifier2) { + modifier2 = atoi(s2_modifier2); } - uwsgi_send_subscription(s_server, s_key, strlen(s_key), modifier1, modifier2, cmd, s_addr, s_sign); + uwsgi_send_subscription(s2_server, s2_key, strlen(s2_key), modifier1, modifier2, cmd, s2_addr, s2_sign); end: - if (s_server) free(s_server); - if (s_key) free(s_key); - if (s_socket) free(s_socket); - if (s_addr) free(s_addr); - if (s_weight) free(s_weight); - if (s_modifier1) free(s_modifier1); - if (s_modifier2) free(s_modifier2); - if (s_sign) free(s_sign); - if (s_check) free(s_check); + if (s2_server) free(s2_server); + if (s2_key) free(s2_key); + if (s2_socket) free(s2_socket); + if (s2_addr) free(s2_addr); + if (s2_weight) free(s2_weight); + if (s2_modifier1) free(s2_modifier1); + if (s2_modifier2) free(s2_modifier2); + if (s2_sign) free(s2_sign); + if (s2_check) free(s2_check); } void uwsgi_subscribe_all(uint8_t cmd, int verbose) { diff --git a/plugins/gevent/gevent.h b/plugins/gevent/gevent.h index 1b2cbc62..89694d2f 100644 --- a/plugins/gevent/gevent.h +++ b/plugins/gevent/gevent.h @@ -14,7 +14,7 @@ int uwsgi_gevent_wait_read_hook(int, int); #define stop_the_watchers_and_clear stop_the_watchers\ Py_DECREF(current); Py_DECREF(current_greenlet);\ Py_DECREF(watcher);\ - if (timer) Py_DECREF(timer); + if (timer) {Py_DECREF(timer);} #define stop_the_io ret = PyObject_CallMethod(watcher, "stop", NULL);\ if (ret) { Py_DECREF(ret); } diff --git a/plugins/http/https.c b/plugins/http/https.c index 77e8acd2..05ff7ec3 100644 --- a/plugins/http/https.c +++ b/plugins/http/https.c @@ -63,33 +63,33 @@ void uwsgi_opt_https(char *opt, char *value, void *cr) { void uwsgi_opt_https2(char *opt, char *value, void *cr) { struct uwsgi_corerouter *ucr = (struct uwsgi_corerouter *) cr; - char *s_addr = NULL; - char *s_cert = NULL; - char *s_key = NULL; - char *s_ciphers = NULL; - char *s_clientca = NULL; - char *s_spdy = NULL; + char *s2_addr = NULL; + char *s2_cert = NULL; + char *s2_key = NULL; + char *s2_ciphers = NULL; + char *s2_clientca = NULL; + char *s2_spdy = NULL; if (uwsgi_kvlist_parse(value, strlen(value), ',', '=', - "addr", &s_addr, - "cert", &s_cert, - "crt", &s_cert, - "key", &s_key, - "ciphers", &s_ciphers, - "clientca", &s_clientca, - "client_ca", &s_clientca, - "spdy", &s_spdy, + "addr", &s2_addr, + "cert", &s2_cert, + "crt", &s2_cert, + "key", &s2_key, + "ciphers", &s2_ciphers, + "clientca", &s2_clientca, + "client_ca", &s2_clientca, + "spdy", &s2_spdy, NULL)) { uwsgi_log("error parsing --https2 option\n"); exit(1); } - if (!s_addr || !s_cert || !s_key) { + if (!s2_addr || !s2_cert || !s2_key) { uwsgi_log("--https2 option needs addr, cert and key items\n"); exit(1); } - struct uwsgi_gateway_socket *ugs = uwsgi_new_gateway_socket(s_addr, ucr->name); + struct uwsgi_gateway_socket *ugs = uwsgi_new_gateway_socket(s2_addr, ucr->name); // ok we have the socket, initialize ssl if required if (!uwsgi.ssl_initialized) { uwsgi_ssl_init(); @@ -102,7 +102,7 @@ void uwsgi_opt_https2(char *opt, char *value, void *cr) { } #ifdef UWSGI_SPDY - if (s_spdy) { + if (s2_spdy) { uhttp.spdy_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL); uhttp.spdy3_settings = uwsgi_buffer_new(uwsgi.page_size); if (uwsgi_buffer_append(uhttp.spdy3_settings, "\x80\x03\x00\x04\x01", 5)) goto spdyerror; @@ -120,12 +120,12 @@ void uwsgi_opt_https2(char *opt, char *value, void *cr) { } #endif - ugs->ctx = uwsgi_ssl_new_server_context(name, s_cert, s_key, s_ciphers, s_clientca); + ugs->ctx = uwsgi_ssl_new_server_context(name, s2_cert, s2_key, s2_ciphers, s2_clientca); if (!ugs->ctx) { exit(1); } #ifdef UWSGI_SPDY - if (s_spdy) { + if (s2_spdy) { SSL_CTX_set_info_callback(ugs->ctx, uwsgi_spdy_info_cb); SSL_CTX_set_next_protos_advertised_cb(ugs->ctx, uwsgi_spdy_npn, NULL); } diff --git a/plugins/sslrouter/sslrouter.c b/plugins/sslrouter/sslrouter.c index e7a374a6..c3e72802 100644 --- a/plugins/sslrouter/sslrouter.c +++ b/plugins/sslrouter/sslrouter.c @@ -75,31 +75,31 @@ static void uwsgi_opt_sslrouter(char *opt, char *value, void *cr) { static void uwsgi_opt_sslrouter2(char *opt, char *value, void *cr) { struct uwsgi_corerouter *ucr = (struct uwsgi_corerouter *) cr; - char *s_addr = NULL; - char *s_cert = NULL; - char *s_key = NULL; - char *s_ciphers = NULL; - char *s_clientca = NULL; + char *s2_addr = NULL; + char *s2_cert = NULL; + char *s2_key = NULL; + char *s2_ciphers = NULL; + char *s2_clientca = NULL; if (uwsgi_kvlist_parse(value, strlen(value), ',', '=', - "addr", &s_addr, - "cert", &s_cert, - "crt", &s_cert, - "key", &s_key, - "ciphers", &s_ciphers, - "clientca", &s_clientca, - "client_ca", &s_clientca, + "addr", &s2_addr, + "cert", &s2_cert, + "crt", &s2_cert, + "key", &s2_key, + "ciphers", &s2_ciphers, + "clientca", &s2_clientca, + "client_ca", &s2_clientca, NULL)) { uwsgi_log("error parsing --sslrouter option\n"); exit(1); } - if (!s_addr || !s_cert || !s_key) { + if (!s2_addr || !s2_cert || !s2_key) { uwsgi_log("--sslrouter option needs addr, cert and key items\n"); exit(1); } - struct uwsgi_gateway_socket *ugs = uwsgi_new_gateway_socket(s_addr, ucr->name); + struct uwsgi_gateway_socket *ugs = uwsgi_new_gateway_socket(s2_addr, ucr->name); // ok we have the socket, initialize ssl if required if (!uwsgi.ssl_initialized) { uwsgi_ssl_init(); @@ -111,7 +111,7 @@ static void uwsgi_opt_sslrouter2(char *opt, char *value, void *cr) { name = uwsgi_concat3(ucr->short_name, "-", ugs->name); } - ugs->ctx = uwsgi_ssl_new_server_context(name, s_cert, s_key, s_ciphers, s_clientca); + ugs->ctx = uwsgi_ssl_new_server_context(name, s2_cert, s2_key, s2_ciphers, s2_clientca); if (!ugs->ctx) { exit(1); } diff --git a/uwsgi.h b/uwsgi.h index 9726a9d1..70bc2f8a 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -136,6 +136,10 @@ extern "C" { #define __need_IOV_MAX #endif +#ifdef __sun__ +#define _XPG4_2 +#define __EXTENSIONS__ +#endif #include #include @@ -167,11 +171,6 @@ extern "C" { #include #endif -#ifdef __sun__ -#define _XPG4_2 -#define __EXTENSIONS__ -#endif - #include #include #include