Skip to content

Commit

Permalink
For #12, refine API for sendmmsg
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed May 3, 2020
1 parent 1537e44 commit 3aa0013
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,16 +743,18 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
}


#if defined(MD_HAVE_SENDMMSG) && defined(_GNU_SOURCE)
int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
int st_sendmmsg(st_netfd_t fd, void *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
{
#if !defined(MD_HAVE_SENDMMSG) || !defined(_GNU_SOURCE)
return -1;
#else
int n;
int left;
struct mmsghdr *p;

left = (int)vlen;
while (left > 0) {
p = msgvec + (vlen - left);
p = (struct mmsghdr*)msgvec + (vlen - left);

if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
if (errno == EINTR)
Expand All @@ -772,8 +774,8 @@ int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int fl
return n;
}
return (int)vlen - left;
}
#endif
}


/*
Expand Down
2 changes: 1 addition & 1 deletion public.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ extern int st_recvfrom(st_netfd_t fd, void *buf, int len, struct sockaddr *from,
extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct sockaddr *to, int tolen, st_utime_t timeout);
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
extern int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
extern int st_sendmmsg(st_netfd_t fd, void *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);

#ifdef DEBUG
Expand Down

0 comments on commit 3aa0013

Please sign in to comment.