From b323894de4da71527492343fd9a313085a16055b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 22 May 1995 09:03:38 +0000 Subject: [PATCH] New argument, block, to cs_open. --- include/gip.h | 7 +++++-- util/gip.c | 6 +++++- util/gips.c | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/include/gip.h b/include/gip.h index 1a85624..9deb525 100644 --- a/include/gip.h +++ b/include/gip.h @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: gip.h,v $ - * Revision 1.3 1995/05/16 09:39:39 adam + * Revision 1.4 1995/05/22 09:03:38 adam + * New argument, block, to cs_open. + * + * Revision 1.3 1995/05/16 09:39:39 adam * LICENSE. * * Revision 1.2 1995/05/01 16:26:43 adam @@ -81,6 +84,6 @@ int gipc_close (GIP gip); GIP gips_initialize (const char *name); int gips_destroy (GIP gip); -int gips_open (GIP gip, const char *client); +int gips_open (GIP gip, const char *client, int block); int gips_close (GIP gip); diff --git a/util/gip.c b/util/gip.c index 0bf516d..806549a 100644 --- a/util/gip.c +++ b/util/gip.c @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: gip.c,v $ - * Revision 1.7 1995/05/16 09:40:52 adam + * Revision 1.8 1995/05/22 09:03:41 adam + * New argument, block, to cs_open. + * + * Revision 1.7 1995/05/16 09:40:52 adam * LICENSE. * * Revision 1.6 1995/05/02 15:26:52 adam @@ -107,6 +110,7 @@ int gip_destroy (GIP gip) { assert (gip); + unlink (gip->name); free (gip->name); free (gip); return 0; diff --git a/util/gips.c b/util/gips.c index 041be4a..70db68c 100644 --- a/util/gips.c +++ b/util/gips.c @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: gips.c,v $ - * Revision 1.6 1995/05/16 09:40:53 adam + * Revision 1.7 1995/05/22 09:03:41 adam + * New argument, block, to cs_open. + * + * Revision 1.6 1995/05/16 09:40:53 adam * LICENSE. * * Revision 1.5 1995/05/01 16:27:29 adam @@ -77,6 +80,8 @@ #include #include +static char *module = "gips"; + GIP gips_initialize (const char *name) { return gip_initialize (name); @@ -87,29 +92,44 @@ int gips_destroy (GIP gip) return gip_destroy (gip); } -int gips_open (GIP gip, const char *client) +int gips_open (GIP gip, const char *client, int block) { - 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); + do + { + gw_log (GW_LOG_DEBUG, module, "open readonly of %s", gip->name); + gip->rfd = open (gip->name, block ? O_RDONLY : (O_RDONLY|O_NONBLOCK)); + gw_log (GW_LOG_DEBUG, module, "got rfd %d", gip->rfd); + } while (gip->rfd == -1 && errno == EINTR); + do + { + gw_log (GW_LOG_DEBUG, module, "open writeonly of %s", client); + gip->wfd = open (client, block ? O_WRONLY : (O_WRONLY|O_NONBLOCK)); + gw_log (GW_LOG_DEBUG, module, "got wfd %d", gip->wfd); + } while (gip->wfd == -1 && errno == EINTR); if (gip->rfd == -1) { + gw_log (GW_LOG_DEBUG|GW_LOG_ERRNO, module, + "cannot open %s", gip->name); if (gip->wfd != -1) { close (gip->wfd); gip->wfd = -1; } + else + gw_log (GW_LOG_DEBUG|GW_LOG_ERRNO, module, + "cannot open %s", client); return -1; } if (gip->wfd == -1) { + gw_log (GW_LOG_DEBUG|GW_LOG_ERRNO, module, + "cannot open %s", client); close (gip->rfd); gip->rfd = -1; return -1; } + 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; -- 1.7.10.4