diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-06-21 03:34:31 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-06-25 22:07:21 +0000 |
commit | f159a33754215eac82b26912bce5592294f9a989 (patch) | |
tree | c5c644bcff6f61d1b7577572206b76f0ff8e1411 /http_put.c | |
parent | fe593c035d50efb5cee7ad10697172ee4072556d (diff) | |
download | cmogstored-f159a33754215eac82b26912bce5592294f9a989.tar.gz |
We cannot assume sa_family_t is the first element of "struct sockaddr_in" or "struct sockaddr_in6". FreeBSD has a "sa_len" member as the first element while Linux does not. So only keep the parts of the "struct sockaddr*" we need and use inet_ntop instead of getnameinfo. This also gives us a little more space to add additional fields to "struct mog_http" in the future without increasing memory (or CPU cache) use.
Diffstat (limited to 'http_put.c')
-rw-r--r-- | http_put.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -444,18 +444,12 @@ MOG_NOINLINE static void read_err_dbg(struct mog_fd *mfd, ssize_t r) { int save_errno = errno; struct mog_ni ni; - struct sockaddr *sa; - const char *addr; const char *path = "(unknown)"; long long bytes = -1; const char *errfmt; - socklen_t len; unsigned last = last_data_recv(mfd->fd); - int rc; - mog_packaddr_read(&mfd->as.http.mpa, &sa, &len); - rc = mog_nameinfo(sa, len, &ni); - addr = rc == 0 ? ni.ni_host : gai_strerror(rc); + mog_nameinfo(&mfd->as.http.mpa, &ni); if (mfd->as.http.forward) { path = mfd->as.http.forward->as.file.path; @@ -466,11 +460,11 @@ MOG_NOINLINE static void read_err_dbg(struct mog_fd *mfd, ssize_t r) errfmt = (r == 0) ? PFX"premature EOF" : PFX"%m"; #undef PFX errno = save_errno; - syslog(LOG_ERR, errfmt, path, addr, ni.ni_serv, bytes); + syslog(LOG_ERR, errfmt, path, ni.ni_host, ni.ni_serv, bytes); if (last != (unsigned)-1) syslog(LOG_ERR, "last_data_recv=%ums from %s%s for PUT %s", - last, addr, ni.ni_serv, path); + last, ni.ni_host, ni.ni_serv, path); } static enum mog_next identity_put_in_progress(struct mog_fd *mfd) |