* 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
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);
* 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
#include <gw-log.h>
#include <gip.h>
+static char *module = "gips";
+
GIP gips_initialize (const char *name)
{
return gip_initialize (name);
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;