aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/IO/IO.c5
-rw-r--r--src/IO/dpi.c34
-rw-r--r--src/IO/http.c13
-rw-r--r--src/cookies.c2
-rw-r--r--src/dns.c9
5 files changed, 17 insertions, 46 deletions
diff --git a/src/IO/IO.c b/src/IO/IO.c
index 1243c70a..a0a8bba5 100644
--- a/src/IO/IO.c
+++ b/src/IO/IO.c
@@ -125,7 +125,6 @@ static void IO_free(IOData_t *io)
*/
static void IO_close_fd(IOData_t *io, int CloseCode)
{
- int st;
int events = 0;
_MSG("====> begin IO_close_fd (%d) Key=%d CloseCode=%d Flags=%d ",
@@ -135,9 +134,7 @@ static void IO_close_fd(IOData_t *io, int CloseCode)
* closed! (other clients may set 'IOFlag_ForceClose') */
if (((io->Flags & IOFlag_ForceClose) || (CloseCode == IO_StopRdWr)) &&
io->FD != -1) {
- do
- st = close(io->FD);
- while (st < 0 && errno == EINTR);
+ dClose(io->FD);
} else {
_MSG(" NOT CLOSING ");
}
diff --git a/src/IO/dpi.c b/src/IO/dpi.c
index 24f1fce8..8e71f8ca 100644
--- a/src/IO/dpi.c
+++ b/src/IO/dpi.c
@@ -86,19 +86,6 @@ void a_Dpi_init(void)
}
/*
- * Close a FD handling EINTR
- */
-static void Dpi_close_fd(int fd)
-{
- int st;
-
- dReturn_if (fd < 0);
- do
- st = close(fd);
- while (st < 0 && errno == EINTR);
-}
-
-/*
* Create a new connection data structure
*/
static dpi_conn_t *Dpi_conn_new(ChainLink *Info)
@@ -362,7 +349,7 @@ static int Dpi_start_dpid(void)
if (pid == 0) {
/* This is the child process. Execute the command. */
char *path1 = dStrconcat(dGethomedir(), "/.dillo/dpid", NULL);
- Dpi_close_fd(st_pipe[0]);
+ dClose(st_pipe[0]);
if (execl(path1, "dpid", (char*)NULL) == -1) {
dFree(path1);
path1 = dStrconcat(DILLO_BINDIR, "dpid", NULL);
@@ -373,7 +360,7 @@ static int Dpi_start_dpid(void)
if (Dpi_blocking_write(st_pipe[1], "ERROR", 5) == -1) {
MSG("Dpi_start_dpid (child): can't write to pipe.\n");
}
- Dpi_close_fd(st_pipe[1]);
+ dClose(st_pipe[1]);
_exit (EXIT_FAILURE);
}
}
@@ -382,19 +369,18 @@ static int Dpi_start_dpid(void)
/* The fork failed. Report failure. */
MSG("Dpi_start_dpid: %s\n", dStrerror(errno));
/* close the unused pipe */
- Dpi_close_fd(st_pipe[0]);
- Dpi_close_fd(st_pipe[1]);
-
+ dClose(st_pipe[0]);
+ dClose(st_pipe[1]);
} else {
/* This is the parent process, check our child status... */
- Dpi_close_fd(st_pipe[1]);
+ dClose(st_pipe[1]);
if ((answer = Dpi_blocking_read(st_pipe[0])) != NULL) {
MSG("Dpi_start_dpid: can't start dpid\n");
dFree(answer);
} else {
ret = 0;
}
- Dpi_close_fd(st_pipe[0]);
+ dClose(st_pipe[0]);
}
return ret;
@@ -467,7 +453,7 @@ static int Dpi_check_dpid_ids()
} else if (connect(sock_fd, (struct sockaddr *)&sin, sin_sz) == -1) {
MSG("Dpi_check_dpid_ids: %s\n", dStrerror(errno));
} else {
- Dpi_close_fd(sock_fd);
+ dClose(sock_fd);
ret = 1;
}
}
@@ -603,7 +589,7 @@ static int Dpi_get_server_port(const char *server_name)
dFree(cmd);
}
dFree(rply);
- Dpi_close_fd(sock_fd);
+ dClose(sock_fd);
return ok ? dpi_port : -1;
}
@@ -648,7 +634,7 @@ static int Dpi_connect_socket(const char *server_name)
}
dFree(cmd);
if (sock_fd != -1 && ret == -1) /* can't send cmd? */
- Dpi_close_fd(sock_fd);
+ dClose(sock_fd);
return ret;
}
@@ -797,7 +783,7 @@ char *a_Dpi_send_blocking_cmd(const char *server_name, const char *cmd)
} if ((ret = Dpi_blocking_read(sock_fd)) == NULL) {
MSG_ERR("[a_Dpi_send_blocking_cmd] Can't read message.\n");
}
- Dpi_close_fd(sock_fd);
+ dClose(sock_fd);
return ret;
}
diff --git a/src/IO/http.c b/src/IO/http.c
index 3e87f912..bb4bca15 100644
--- a/src/IO/http.c
+++ b/src/IO/http.c
@@ -210,17 +210,6 @@ static void Http_socket_free(int SKey)
}
/*
- * Close the socket's FD
- */
-static void Http_socket_close(SocketData_t *S)
-{
- int st;
- do
- st = close(S->SockFD);
- while (st < 0 && errno == EINTR);
-}
-
-/*
* Make the HTTP header's Referer line according to preferences
* (default is "host" i.e. "scheme://hostname/" )
*/
@@ -448,7 +437,7 @@ static int Http_connect_socket(ChainLink *Info)
status = connect(S->SockFD, (struct sockaddr *)&name, socket_len);
if (status == -1 && errno != EINPROGRESS) {
S->Err = errno;
- Http_socket_close(S);
+ dClose(S->SockFD);
MSG("Http_connect_socket ERROR: %s\n", dStrerror(S->Err));
} else {
a_Chain_bcb(OpSend, Info, &S->SockFD, "FD");
diff --git a/src/cookies.c b/src/cookies.c
index e43a74a2..deaae2ab 100644
--- a/src/cookies.c
+++ b/src/cookies.c
@@ -90,7 +90,7 @@ static FILE *Cookies_fopen(const char *filename, char *init_str)
filename, dStrerror(errno));
}
}
- close(fd);
+ dClose(fd);
MSG("Cookies: Created file: %s\n", filename);
F_in = fopen(filename, "r");
diff --git a/src/dns.c b/src/dns.c
index 7ae19fe4..e288e8cc 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -217,9 +217,8 @@ void a_Dns_init(void)
/* If the IPv6 address family is not available there is no point
wasting time trying to connect to v6 addresses. */
int fd = socket(AF_INET6, SOCK_STREAM, 0);
- if (fd >= 0) {
- close(fd);
- }
+ if (fd >= 0)
+ dClose(fd);
}
#endif
}
@@ -510,8 +509,8 @@ void a_Dns_freeall(void)
dList_free(dns_cache[i].addr_list);
}
a_IOwatch_remove_fd(dns_notify_pipe[0], DIO_READ);
- close(dns_notify_pipe[0]);
- close(dns_notify_pipe[1]);
+ dClose(dns_notify_pipe[0]);
+ dClose(dns_notify_pipe[1]);
dFree(dns_cache);
}