diff options
author | Unbit <info@unbit.it> | 2014-01-09 12:59:36 +0100 |
---|---|---|
committer | Unbit <info@unbit.it> | 2014-01-09 12:59:36 +0100 |
commit | 8eebc9f4007e83d9f0f54bcfc5729723bfba8dcb (patch) | |
tree | d895d588ea374098ef0a2b6b3ec715363bbb10f8 /core/notify.c | |
parent | 2ad6a1c8e8089ca974186a5f2d509de62263e245 (diff) | |
download | uwsgi-8eebc9f4007e83d9f0f54bcfc5729723bfba8dcb.tar.gz |
allows passing notify object to subscription packets
Diffstat (limited to 'core/notify.c')
-rw-r--r-- | core/notify.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/notify.c b/core/notify.c index 66516042..7c08d681 100644 --- a/core/notify.c +++ b/core/notify.c @@ -92,3 +92,22 @@ int uwsgi_notify_socket_manage(int fd) { return 0; } +int uwsgi_notify_msg(char *dst, char *msg, size_t len) { + static int notify_fd = -1; + if (notify_fd < 0) { + notify_fd = socket(AF_UNIX, SOCK_DGRAM, 0); + if (notify_fd < 0) { + uwsgi_error("uwsgi_notify_msg()/socket()"); + return -1; + } + } + struct sockaddr_un un_addr; + memset(&un_addr, 0, sizeof(struct sockaddr_un)); + un_addr.sun_family = AF_UNIX; + // use 102 as the magic number + strncat(un_addr.sun_path, dst, 102); + if (sendto(notify_fd, msg, len, 0, (struct sockaddr *) &un_addr, sizeof(un_addr)) < 0) { + return -1; + } + return 0; +} |