aboutsummaryrefslogtreecommitdiff
path: root/mfd/srvman.c
diff options
context:
space:
mode:
Diffstat (limited to 'mfd/srvman.c')
-rw-r--r--mfd/srvman.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mfd/srvman.c b/mfd/srvman.c
index 47a5b54d..67433858 100644
--- a/mfd/srvman.c
+++ b/mfd/srvman.c
@@ -45,6 +45,7 @@ struct mfd_server {
45 socklen_t salen; /* Length of the sa */ 45 socklen_t salen; /* Length of the sa */
46 int backlog; /* Backlog value for listen(2) */ 46 int backlog; /* Backlog value for listen(2) */
47 int fd; /* Socket descriptor */ 47 int fd; /* Socket descriptor */
48 int flags; /* SRV_* flags */
48 mfd_server_prefork_hook_t prefork_hook; /* Pre-fork function */ 49 mfd_server_prefork_hook_t prefork_hook; /* Pre-fork function */
49 mfd_server_func_t conn; /* Connection handler */ 50 mfd_server_func_t conn; /* Connection handler */
50 mfd_srvman_hook_t free_hook; 51 mfd_srvman_hook_t free_hook;
@@ -378,7 +379,7 @@ mfd_server_shutdown(struct mfd_server *srv)
378} 379}
379 380
380struct mfd_server * 381struct mfd_server *
381mfd_server_new(const char *id, mu_url_t url, mfd_server_func_t conn) 382mfd_server_new(const char *id, mu_url_t url, mfd_server_func_t conn, int flags)
382{ 383{
383 struct mfd_server *srv; 384 struct mfd_server *srv;
384 struct sockaddr *sa; 385 struct sockaddr *sa;
@@ -394,6 +395,7 @@ mfd_server_new(const char *id, mu_url_t url, mfd_server_func_t conn)
394 srv->salen = salen; 395 srv->salen = salen;
395 srv->backlog = 8; 396 srv->backlog = 8;
396 srv->conn = conn; 397 srv->conn = conn;
398 srv->flags = flags;
397 return srv; 399 return srv;
398} 400}
399 401
@@ -496,7 +498,7 @@ server_run(int connfd, struct mfd_server *srv,
496 if (srv->acl && check_acl(srv->id, srv->acl, sa, salen)) 498 if (srv->acl && check_acl(srv->id, srv->acl, sa, salen))
497 return; 499 return;
498 500
499 if (single_process_option) { 501 if (single_process_option || (srv->flags & SRV_SINGLE_PROCESS)) {
500 if ((!srvman_param.prefork_hook 502 if ((!srvman_param.prefork_hook
501 || srvman_param.prefork_hook(sa, salen, 503 || srvman_param.prefork_hook(sa, salen,
502 srvman_param.data) == 0) 504 srvman_param.data) == 0)
@@ -707,7 +709,8 @@ server_prep(struct mfd_server *srv, int fd)
707 mu_error(_("%s: file %s is not a socket"), 709 mu_error(_("%s: file %s is not a socket"),
708 srv->id, s_un->sun_path); 710 srv->id, s_un->sun_path);
709 return 1; 711 return 1;
710 } else if (force_remove) { 712 } else if (force_remove
713 || !(srv->flags & SRV_KEEP_EXISTING)) {
711 if (unlink(s_un->sun_path)) { 714 if (unlink(s_un->sun_path)) {
712 mu_error(_("%s: cannot unlink file %s: %s"), 715 mu_error(_("%s: cannot unlink file %s: %s"),
713 srv->id, s_un->sun_path, 716 srv->id, s_un->sun_path,
@@ -722,7 +725,7 @@ server_prep(struct mfd_server *srv, int fd)
722 break; 725 break;
723 726
724 case AF_INET: 727 case AF_INET:
725 if (force_remove) { 728 if (force_remove || !(srv->flags & SRV_KEEP_EXISTING)) {
726 t = 1; 729 t = 1;
727 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 730 setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
728 &t, sizeof(t)); 731 &t, sizeof(t));

Return to:

Send suggestions and report system problems to the System administrator.