about summary refs log tree commit homepage
path: root/cmogstored.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-06-21 03:34:31 +0000
committerEric Wong <normalperson@yhbt.net>2013-06-25 22:07:21 +0000
commitf159a33754215eac82b26912bce5592294f9a989 (patch)
treec5c644bcff6f61d1b7577572206b76f0ff8e1411 /cmogstored.h
parentfe593c035d50efb5cee7ad10697172ee4072556d (diff)
downloadcmogstored-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 'cmogstored.h')
-rw-r--r--cmogstored.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/cmogstored.h b/cmogstored.h
index 7b1f164..580de8d 100644
--- a/cmogstored.h
+++ b/cmogstored.h
@@ -235,7 +235,7 @@ struct mog_queue {
 
 /* accept.c */
 typedef void (*mog_post_accept_fn)(int fd, struct mog_svc *,
-                                struct sockaddr *, socklen_t);
+                                union mog_sockaddr *, socklen_t);
 struct mog_accept {
         struct mog_svc *svc;
         mog_post_accept_fn post_accept_fn;
@@ -414,7 +414,7 @@ void mog_thrpool_set_size(struct mog_thrpool *, size_t size);
 /* mgmt.c */
 void mog_mgmt_writev(struct mog_mgmt *, struct iovec *, int iovcnt);
 void mog_mgmt_post_accept(int fd, struct mog_svc *,
-                                struct sockaddr *, socklen_t);
+                                union mog_sockaddr *, socklen_t);
 enum mog_next mog_mgmt_queue_step(struct mog_fd *) MOG_CHECK;
 void mog_mgmt_quit_step(struct mog_fd *);
 
@@ -469,9 +469,9 @@ enum mog_next mog_http_get_in_progress(struct mog_fd *);
 
 /* http.c */
 void mog_http_post_accept(int fd, struct mog_svc *,
-                                struct sockaddr *, socklen_t);
+                                union mog_sockaddr *, socklen_t);
 void mog_httpget_post_accept(int fd, struct mog_svc *,
-                                struct sockaddr *, socklen_t);
+                                union mog_sockaddr *, socklen_t);
 enum mog_next mog_http_queue_step(struct mog_fd *) MOG_CHECK;
 void mog_http_quit_step(struct mog_fd *);
 char *mog_http_path(struct mog_http *, char *buf);
@@ -582,6 +582,7 @@ pid_t mog_upgrade_spawn(void);
 /* exit.c */
 _Noreturn void cmogstored_exit(void);
 
+verify(sizeof(in_port_t) <= sizeof(uint16_t));
 /*
  * We only deal with ipv4 and ipv6 addresses (and no human-friendly
  * hostnames/service names), so we can use smaller constants than the
@@ -594,4 +595,4 @@ struct mog_ni {
 };
 
 /* nameinfo.c */
-int mog_nameinfo(struct sockaddr *, socklen_t, struct mog_ni *);
+void mog_nameinfo(struct mog_packaddr *, struct mog_ni *);