Skip to content

Commit

Permalink
thunder lock (sigh)
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@natty32 committed Jul 7, 2011
1 parent bde996d commit 11f9b04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils.c
Expand Up @@ -768,8 +768,10 @@ int wsgi_req_accept(int queue, struct wsgi_request *wsgi_req) {
char uwsgi_signal;
struct uwsgi_socket *uwsgi_sock = uwsgi.sockets;

uwsgi_lock(uwsgi.thunder_lock);
ret = event_queue_wait(queue, uwsgi.edge_triggered - 1, &interesting_fd);
if (ret < 0) {
uwsgi_unlock(uwsgi.thunder_lock);
return -1;
}

Expand All @@ -779,6 +781,9 @@ int wsgi_req_accept(int queue, struct wsgi_request *wsgi_req) {
#endif

if (uwsgi.signal_socket > -1 && (interesting_fd == uwsgi.signal_socket || interesting_fd == uwsgi.my_signal_socket)) {

uwsgi_unlock(uwsgi.thunder_lock);

if (read(interesting_fd, &uwsgi_signal, 1) <= 0) {
if (uwsgi.no_orphans) {
uwsgi_log_verbose("uWSGI worker %d screams: UAAAAAAH my master died, i will follow him...\n", uwsgi.mywid);
Expand Down Expand Up @@ -808,6 +813,7 @@ int wsgi_req_accept(int queue, struct wsgi_request *wsgi_req) {
if (interesting_fd == uwsgi_sock->fd || (uwsgi.edge_triggered && uwsgi_sock->edge_trigger)) {
wsgi_req->socket = uwsgi_sock;
wsgi_req->poll.fd = wsgi_req->socket->proto_accept(wsgi_req, interesting_fd);
uwsgi_unlock(uwsgi.thunder_lock);
if (wsgi_req->poll.fd < 0) {
#ifdef UWSGI_THREADING
if (uwsgi.threads > 1) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &ret);
Expand Down Expand Up @@ -842,6 +848,7 @@ int wsgi_req_accept(int queue, struct wsgi_request *wsgi_req) {
uwsgi_sock = uwsgi_sock->next;
}

uwsgi_unlock(uwsgi.thunder_lock);
#ifdef UWSGI_THREADING
if (uwsgi.threads > 1) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &ret);
#endif
Expand Down
4 changes: 4 additions & 0 deletions uwsgi.c
Expand Up @@ -1556,6 +1556,10 @@ int uwsgi_start(void *v_argv) {
}


// event queue lock (avoid same oevent on multiple queues)
uwsgi.thunder_lock = uwsgi_mmap_shared_lock();
uwsgi_lock_init(uwsgi.thunder_lock);

// application generic lock
uwsgi.user_lock = uwsgi_mmap_shared_lock();
uwsgi_lock_init(uwsgi.user_lock);
Expand Down
2 changes: 2 additions & 0 deletions uwsgi.h
Expand Up @@ -1244,6 +1244,8 @@ struct uwsgi_server {
size_t queue_filesize;
int queue_store_sync;

void *thunder_lock;

void *cache_lock;
void *queue_lock;
void *user_lock;
Expand Down

0 comments on commit 11f9b04

Please sign in to comment.