Browse Source

[Minor] Explicitly specify af for socketpair

tags/2.6
Vsevolod Stakhov 4 years ago
parent
commit
980d8b7d6b
5 changed files with 11 additions and 13 deletions
  1. 1
    1
      src/libserver/rspamd_control.c
  2. 2
    2
      src/libserver/worker_util.c
  3. 6
    8
      src/libutil/util.c
  4. 1
    1
      src/libutil/util.h
  5. 1
    1
      src/lua/lua_worker.c

+ 1
- 1
src/libserver/rspamd_control.c View File

@@ -914,7 +914,7 @@ rspamd_srv_handler (EV_P_ ev_io *w, int revents)
if (spair == NULL) {
spair = g_malloc (sizeof (gint) * 2);

if (rspamd_socketpair (spair, 0) == -1) {
if (rspamd_socketpair (spair, cmd.cmd.spair.af) == -1) {
rdata->rep.reply.spair.code = errno;
msg_err ("cannot create socket pair: %s", strerror (errno));
}

+ 2
- 2
src/libserver/worker_util.c View File

@@ -1136,12 +1136,12 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main,
/* Starting worker process */
wrk = (struct rspamd_worker *) g_malloc0 (sizeof (struct rspamd_worker));

if (!rspamd_socketpair (wrk->control_pipe, 0)) {
if (!rspamd_socketpair (wrk->control_pipe, SOCK_DGRAM)) {
msg_err ("socketpair failure: %s", strerror (errno));
rspamd_hard_terminate (rspamd_main);
}

if (!rspamd_socketpair (wrk->srv_pipe, 0)) {
if (!rspamd_socketpair (wrk->srv_pipe, SOCK_DGRAM)) {
msg_err ("socketpair failure: %s", strerror (errno));
rspamd_hard_terminate (rspamd_main);
}

+ 6
- 8
src/libutil/util.c View File

@@ -442,23 +442,21 @@ rspamd_socket (const gchar *credits, guint16 port,
}

gboolean
rspamd_socketpair (gint pair[2], gboolean is_stream)
rspamd_socketpair (gint pair[2], gint af)
{
gint r, serrno;
gint r = -1, serrno;

if (!is_stream) {
#ifdef HAVE_SOCK_SEQPACKET
if (af == SOCK_SEQPACKET) {
r = socketpair (AF_LOCAL, SOCK_SEQPACKET, 0, pair);

if (r == -1) {
r = socketpair (AF_LOCAL, SOCK_DGRAM, 0, pair);
}
#else
r = socketpair (AF_LOCAL, SOCK_DGRAM, 0, pair);
#endif
}
else {
r = socketpair (AF_LOCAL, SOCK_STREAM, 0, pair);
#endif
if (r == -1) {
r = socketpair (AF_LOCAL, af, 0, pair);
}

if (r == -1) {

+ 1
- 1
src/libutil/util.h View File

@@ -66,7 +66,7 @@ gint rspamd_socket (const gchar *credits, guint16 port, gint type,
/*
* Create socketpair
*/
gboolean rspamd_socketpair (gint pair[2], gboolean is_stream);
gboolean rspamd_socketpair (gint pair[2], gint af);

/*
* Make specified socket non-blocking

+ 1
- 1
src/lua/lua_worker.c View File

@@ -786,7 +786,7 @@ lua_worker_spawn_process (lua_State *L)
cbdata->out_pos = 0;
}

if (rspamd_socketpair (cbdata->sp, TRUE) == -1) {
if (rspamd_socketpair (cbdata->sp, SOCK_STREAM) == -1) {
msg_err ("cannot spawn socketpair: %s", strerror (errno));
luaL_unref (L, LUA_REGISTRYINDEX, cbdata->func_cbref);
luaL_unref (L, LUA_REGISTRYINDEX, cbdata->cb_cbref);

Loading…
Cancel
Save