X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fgips.c;h=90e1256fd95f2af3732f4c8b18ccde77e742e6f7;hb=25db261b6bbbfcc7bc26f679f195b51d31b9d7d7;hp=041be4a6518d27a2ac20bb7172886ca9f00e4ac9;hpb=e1ec9d39463f431383547891f38e30f2ff17842c;p=egate.git diff --git a/util/gips.c b/util/gips.c index 041be4a..90e1256 100644 --- a/util/gips.c +++ b/util/gips.c @@ -45,7 +45,13 @@ * Europagate, 1995 * * $Log: gips.c,v $ - * Revision 1.6 1995/05/16 09:40:53 adam + * Revision 1.8 1995/05/22 11:43:01 adam + * Minor changes on dtbsun - include of errno.h. + * + * 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 @@ -73,10 +79,13 @@ #include #include #include +#include #include #include +static char *module = "gips"; + GIP gips_initialize (const char *name) { return gip_initialize (name); @@ -87,29 +96,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;