Skip to content

Commit

Permalink
core: tcp - more details on error log messages
Browse files Browse the repository at this point in the history
(cherry picked from commit fefb3f1)
(cherry picked from commit f6ad586)
  • Loading branch information
miconda committed Jul 16, 2020
1 parent 208dec0 commit ed095a9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
53 changes: 28 additions & 25 deletions src/core/io_wait.h
Expand Up @@ -418,13 +418,13 @@ inline static int io_watch_add( io_wait_h* h,
*/
/* set async & signal */
if (fcntl(fd, F_SETOWN, my_pid())==-1){
LM_ERR("fnctl: SETOWN failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("fnctl: SETOWN on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
if (fcntl(fd, F_SETSIG, h->signo)==-1){
LM_ERR("fnctl: SETSIG failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("fnctl: SETSIG on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
/* set both non-blocking and async */
Expand Down Expand Up @@ -458,7 +458,8 @@ inline static int io_watch_add( io_wait_h* h,
n=epoll_ctl(h->epfd, EPOLL_CTL_ADD, fd, &ep_event);
if (unlikely(n==-1)){
if (errno==EAGAIN) goto again1;
LM_ERR("epoll_ctl failed: %s [%d]\n", strerror(errno), errno);
LM_ERR("epoll_ctl on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
break;
Expand All @@ -478,7 +479,8 @@ inline static int io_watch_add( io_wait_h* h,
n=epoll_ctl(h->epfd, EPOLL_CTL_ADD, fd, &ep_event);
if (unlikely(n==-1)){
if (errno==EAGAIN) goto again2;
LM_ERR("epoll_ctl failed: %s [%d]\n", strerror(errno), errno);
LM_ERR("epoll_ctl on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
break;
Expand Down Expand Up @@ -508,8 +510,8 @@ inline static int io_watch_add( io_wait_h* h,
again_devpoll:
if (write(h->dpoll_fd, &pfd, sizeof(pfd))==-1){
if (errno==EAGAIN) goto again_devpoll;
LM_ERR("/dev/poll write failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("/dev/poll write of fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
break;
Expand All @@ -535,7 +537,8 @@ inline static int io_watch_add( io_wait_h* h,
(pf.revents & (e->events|POLLERR|POLLHUP)));
if (unlikely(e->type && (n==-1))){
if (errno==EINTR) goto check_io_again;
LM_ERR("check_io poll: %s [%d]\n", strerror(errno), errno);
LM_ERR("check_io poll on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
}
}
#endif
Expand Down Expand Up @@ -640,13 +643,13 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, int flags)
/* reset ASYNC */
fd_flags=fcntl(fd, F_GETFL);
if (unlikely(fd_flags==-1)){
LM_ERR("fnctl: GETFL failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("fnctl: GETFL on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
if (unlikely(fcntl(fd, F_SETFL, fd_flags&(~O_ASYNC))==-1)){
LM_ERR("fnctl: SETFL failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("fnctl: SETFL on fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
fix_fd_array; /* only on success */
Expand All @@ -667,8 +670,8 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, int flags)
n=epoll_ctl(h->epfd, EPOLL_CTL_DEL, fd, &ep_event);
if (unlikely(n==-1)){
if (errno==EAGAIN) goto again_epoll;
LM_ERR("removing fd from epoll list failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("removing fd %d from epoll list failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
#ifdef EPOLL_NO_CLOSE_BUG
Expand Down Expand Up @@ -707,8 +710,8 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, int flags)
again_devpoll:
if (write(h->dpoll_fd, &pfd, sizeof(pfd))==-1){
if (errno==EINTR) goto again_devpoll;
LM_ERR("removing fd from /dev/poll failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("removing fd %d from /dev/poll failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
break;
Expand Down Expand Up @@ -834,8 +837,8 @@ inline static int io_watch_chg(io_wait_h* h, int fd, short events, int idx )
n=epoll_ctl(h->epfd, EPOLL_CTL_MOD, fd, &ep_event);
if (unlikely(n==-1)){
if (errno==EAGAIN) goto again_epoll_lt;
LM_ERR("modifying epoll events failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("modifying epoll events of fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
break;
Expand All @@ -854,8 +857,8 @@ inline static int io_watch_chg(io_wait_h* h, int fd, short events, int idx )
n=epoll_ctl(h->epfd, EPOLL_CTL_MOD, fd, &ep_event);
if (unlikely(n==-1)){
if (errno==EAGAIN) goto again_epoll_et;
LM_ERR("modifying epoll events failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("modifying epoll events of fd %d failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
break;
Expand Down Expand Up @@ -890,17 +893,17 @@ inline static int io_watch_chg(io_wait_h* h, int fd, short events, int idx )
again_devpoll1:
if (unlikely(write(h->dpoll_fd, &pfd, sizeof(pfd))==-1)){
if (errno==EINTR) goto again_devpoll1;
LM_ERR("removing fd from /dev/poll failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("removing fd %d from /dev/poll failed: %s [%d]\n",
fd, strerror(errno), errno);
goto error;
}
again_devpoll2:
pfd.events=events;
pfd.revents=0;
if (unlikely(write(h->dpoll_fd, &pfd, sizeof(pfd))==-1)){
if (errno==EINTR) goto again_devpoll2;
LM_ERR("re-adding fd to /dev/poll failed: %s [%d]\n",
strerror(errno), errno);
LM_ERR("re-adding fd %d to /dev/poll failed: %s [%d]\n",
fd, strerror(errno), errno);
/* error re-adding the fd => mark it as removed/unhash */
unhash_fd_map(e);
goto error;
Expand Down
7 changes: 5 additions & 2 deletions src/core/tcp_read.c
Expand Up @@ -1858,8 +1858,11 @@ inline static int handle_io(struct fd_map* fm, short events, int idx)
if (unlikely(con->state==S_CONN_BAD)){
resp=CONN_ERROR;
if (!(con->send_flags.f & SND_F_CON_CLOSE))
LM_WARN("F_TCPCONN connection marked as bad: %p id %d refcnt %d\n",
con, con->id, atomic_get(&con->refcnt));
LM_WARN("F_TCPCONN connection marked as bad: %p id %d fd %d"
" refcnt %d ([%s]:%u -> [%s]:%u)\n",
con, con->id, con->fd, atomic_get(&con->refcnt),
ip_addr2a(&con->rcv.src_ip), con->rcv.src_port,
ip_addr2a(&con->rcv.dst_ip), con->rcv.dst_port);
goto read_error;
}
read_flags=((
Expand Down

0 comments on commit ed095a9

Please sign in to comment.