From: Adam Dickmeiss Date: Mon, 1 May 1995 16:27:28 +0000 (+0000) Subject: Various improvements. Close-on-exec and close on failure on either X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=28721a4e39c970cb2d13109baf5bb0f2e43a15a1;p=egate.git Various improvements. Close-on-exec and close on failure on either read or write FIFO. --- diff --git a/util/gip.c b/util/gip.c index ba09b69..f0c02a4 100644 --- a/util/gip.c +++ b/util/gip.c @@ -2,7 +2,11 @@ * Europagate, 1995 * * $Log: gip.c,v $ - * Revision 1.4 1995/04/21 16:38:07 adam + * Revision 1.5 1995/05/01 16:27:28 adam + * Various improvements. Close-on-exec and close on failure on either + * read or write FIFO. + * + * Revision 1.4 1995/04/21 16:38:07 adam * Added more debugging logs. * * Revision 1.3 1995/04/20 15:12:42 adam @@ -64,6 +68,11 @@ int gip_infileno (GIP gip) return gip->rfd; } +int gip_outfileno (GIP gip) +{ + return gip->wfd; +} + int gip_errno (GIP gip) { return gip->errno; diff --git a/util/gipc.c b/util/gipc.c index 1232341..cb0b697 100644 --- a/util/gipc.c +++ b/util/gipc.c @@ -2,7 +2,11 @@ * Europagate, 1995 * * $Log: gipc.c,v $ - * Revision 1.5 1995/04/21 16:38:07 adam + * Revision 1.6 1995/05/01 16:27:29 adam + * Various improvements. Close-on-exec and close on failure on either + * read or write FIFO. + * + * Revision 1.5 1995/04/21 16:38:07 adam * Added more debugging logs. * * Revision 1.4 1995/04/20 15:12:45 adam @@ -44,28 +48,45 @@ int gipc_open (GIP gip, const char *server, int sync) { if (sync) { - gw_log (GW_LOG_DEBUG, "gipc", "Open writeonly of %s", server); + gw_log (GW_LOG_DEBUG, "gipc", "Open sync writeonly of %s", server); gip->wfd = open (server, O_WRONLY); - gw_log (GW_LOG_DEBUG, "gipc", "Open readonly of %s", gip->name); + gw_log (GW_LOG_DEBUG, "gipc", "got wfd %d", gip->wfd); + + gw_log (GW_LOG_DEBUG, "gipc", "Open sync readonly of %s", gip->name); gip->rfd = open (gip->name, O_RDONLY); + gw_log (GW_LOG_DEBUG, "gipc", "got rfd %d", gip->rfd); } else { + gw_log (GW_LOG_DEBUG, "gipc", "Open readonly of %s", gip->name); gip->rfd = open (gip->name, O_RDONLY|O_NONBLOCK); + gw_log (GW_LOG_DEBUG, "gipc", "got rfd %d", gip->rfd); + + gw_log (GW_LOG_DEBUG, "gipc", "Open witeonly of %s", server); gip->wfd = open (server, O_WRONLY|O_NONBLOCK); + gw_log (GW_LOG_DEBUG, "gipc", "got wfd %d", gip->wfd); } if (gip->rfd == -1) { gw_log (GW_LOG_DEBUG, "gipc", "Cannot open %s", gip->name); + if (gip->wfd != -1) + { + close (gip->wfd); + gip->wfd = -1; + } return -1; } if (gip->wfd == -1) { gw_log (GW_LOG_DEBUG, "gipc", "Cannot open %s", server); + close (gip->rfd); + gip->rfd = -1; return -2; } fcntl (gip->wfd, F_SETFL, 0); fcntl (gip->rfd, F_SETFL, 0); + fcntl (gip->wfd, F_SETFD, FD_CLOEXEC); + fcntl (gip->rfd, F_SETFD, FD_CLOEXEC); return 0; } diff --git a/util/gips.c b/util/gips.c index 79eee64..9b48e9d 100644 --- a/util/gips.c +++ b/util/gips.c @@ -2,7 +2,11 @@ * Europagate, 1995 * * $Log: gips.c,v $ - * Revision 1.4 1995/04/21 16:38:08 adam + * Revision 1.5 1995/05/01 16:27:29 adam + * Various improvements. Close-on-exec and close on failure on either + * read or write FIFO. + * + * Revision 1.4 1995/04/21 16:38:08 adam * Added more debugging logs. * * Revision 1.3 1995/04/20 15:12:46 adam @@ -41,12 +45,27 @@ int gips_open (GIP gip, const char *client) { gw_log (GW_LOG_DEBUG, "gips", "open readonly of %s", gip->name); gip->rfd = open (gip->name, O_RDONLY); + gw_log (GW_LOG_DEBUG, "gips", "got rfd %d", gip->rfd); gw_log (GW_LOG_DEBUG, "gips", "open writeonly of %s", client); gip->wfd = open (client, O_WRONLY); + gw_log (GW_LOG_DEBUG, "gips", "got wfd %d", gip->wfd); if (gip->rfd == -1) + { + if (gip->wfd != -1) + { + close (gip->wfd); + gip->wfd = -1; + } return -1; + } if (gip->wfd == -1) + { + close (gip->rfd); + gip->rfd = -1; return -1; + } + fcntl (gip->wfd, F_SETFD, FD_CLOEXEC); + fcntl (gip->rfd, F_SETFD, FD_CLOEXEC); return 0; }