Skip to content

Commit

Permalink
Update InkAPITest.cc for new con.sock field (#11674)
Browse files Browse the repository at this point in the history
* Constify buffer parameters on socket write methods

* Update InkAPITest.cc for new `con.sock` field
  • Loading branch information
JosiahWI authored Aug 13, 2024
1 parent 50f5f23 commit fc5918e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions include/iocore/eventsystem/UnixSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ class UnixSocket
int recvmmsg(struct mmsghdr *msgvec, int vlen, int flags, struct timespec *timeout) const;
#endif

std::int64_t write(void *buf, int size) const;
std::int64_t write(void const *buf, int size) const;

int send(void *buf, int size, int flags) const;
int sendto(void *buf, int size, int flags, struct sockaddr const *to, int tolen) const;
int send(void const *buf, int size, int flags) const;
int sendto(void const *buf, int size, int flags, struct sockaddr const *to, int tolen) const;
int sendmsg(struct msghdr const *m, int flags) const;

static int poll(struct pollfd *fds, unsigned long nfds, int timeout);
Expand Down Expand Up @@ -203,7 +203,7 @@ UnixSocket::recvmmsg(struct mmsghdr *msgvec, int vlen, int flags, struct timespe
#endif

inline std::int64_t
UnixSocket::write(void *buf, int size) const
UnixSocket::write(void const *buf, int size) const
{
std::int64_t r;
do {
Expand All @@ -216,19 +216,19 @@ UnixSocket::write(void *buf, int size) const
}

inline int
UnixSocket::send(void *buf, int size, int flags) const
UnixSocket::send(void const *buf, int size, int flags) const
{
int r;
do {
if (unlikely((r = ::send(this->fd, static_cast<char *>(buf), size, flags)) < 0)) {
if (unlikely((r = ::send(this->fd, static_cast<char const *>(buf), size, flags)) < 0)) {
r = -errno;
}
} while (r == -EINTR);
return r;
}

inline int
UnixSocket::sendto(void *buf, int len, int flags, struct sockaddr const *to, int tolen) const
UnixSocket::sendto(void const *buf, int len, int flags, struct sockaddr const *to, int tolen) const
{
int r;
do {
Expand Down
2 changes: 1 addition & 1 deletion src/api/InkAPITest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ client_handler(TSCont contp, TSEvent event, void *data)
// happen until data arrives on the socket. Because we're just testing the accept()
// we write a small amount of ignored data to make sure this gets triggered.
UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(data);
ink_release_assert(::write(vc->con.fd, "Bob's your uncle", 16) != 0);
ink_release_assert(vc->con.sock.write("Bob's your uncle", 16) != 0);

sleep(1); // XXX this sleep ensures the server end gets the accept event.

Expand Down

0 comments on commit fc5918e

Please sign in to comment.