Skip to content

Commit 3aa0013

Browse files
committed
For #12, refine API for sendmmsg
1 parent 1537e44 commit 3aa0013

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

io.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -743,16 +743,18 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
743743
}
744744

745745

746-
#if defined(MD_HAVE_SENDMMSG) && defined(_GNU_SOURCE)
747-
int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
746+
int st_sendmmsg(st_netfd_t fd, void *msgvec, unsigned int vlen, int flags, st_utime_t timeout)
748747
{
748+
#if !defined(MD_HAVE_SENDMMSG) || !defined(_GNU_SOURCE)
749+
return -1;
750+
#else
749751
int n;
750752
int left;
751753
struct mmsghdr *p;
752754

753755
left = (int)vlen;
754756
while (left > 0) {
755-
p = msgvec + (vlen - left);
757+
p = (struct mmsghdr*)msgvec + (vlen - left);
756758

757759
if ((n = sendmmsg(fd->osfd, p, left, flags)) < 0) {
758760
if (errno == EINTR)
@@ -772,8 +774,8 @@ int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int fl
772774
return n;
773775
}
774776
return (int)vlen - left;
775-
}
776777
#endif
778+
}
777779

778780

779781
/*

public.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ extern int st_recvfrom(st_netfd_t fd, void *buf, int len, struct sockaddr *from,
151151
extern int st_sendto(st_netfd_t fd, const void *msg, int len, const struct sockaddr *to, int tolen, st_utime_t timeout);
152152
extern int st_recvmsg(st_netfd_t fd, struct msghdr *msg, int flags, st_utime_t timeout);
153153
extern int st_sendmsg(st_netfd_t fd, const struct msghdr *msg, int flags, st_utime_t timeout);
154-
extern int st_sendmmsg(st_netfd_t fd, struct mmsghdr *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
154+
extern int st_sendmmsg(st_netfd_t fd, void *msgvec, unsigned int vlen, int flags, st_utime_t timeout);
155155
extern st_netfd_t st_open(const char *path, int oflags, mode_t mode);
156156

157157
#ifdef DEBUG

0 commit comments

Comments
 (0)