Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROTON-2791: Add MSG_MORE send flag on raw connections #420

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions c/src/proactor/epoll_raw_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,10 @@ task_t *pni_raw_connection_task(praw_connection_t *rc) {
return &rc->task;
}

static long snd(int fd, const void* b, size_t s) {
return send(fd, b, s, MSG_NOSIGNAL | MSG_DONTWAIT);
static long snd(int fd, const void* b, size_t s, bool more) {
int flags = MSG_NOSIGNAL | MSG_DONTWAIT;
if (more) flags |= MSG_MORE;
return send(fd, b, s, flags);
}

static long rcv(int fd, void* b, size_t s) {
Expand Down
2 changes: 1 addition & 1 deletion c/src/proactor/raw_connection-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void pni_raw_close(pn_raw_connection_t *conn);
void pni_raw_read_close(pn_raw_connection_t *conn);
void pni_raw_write_close(pn_raw_connection_t *conn);
void pni_raw_read(pn_raw_connection_t *conn, int sock, long (*recv)(int, void*, size_t), void (*set_error)(pn_raw_connection_t *, const char *, int));
void pni_raw_write(pn_raw_connection_t *conn, int sock, long (*send)(int, const void*, size_t), void (*set_error)(pn_raw_connection_t *, const char *, int));
void pni_raw_write(pn_raw_connection_t *conn, int sock, long (*send)(int, const void*, size_t, bool), void (*set_error)(pn_raw_connection_t *, const char *, int));
void pni_raw_process_shutdown(pn_raw_connection_t *conn, int sock, int (*shutdown_rd)(int), int (*shutdown_wr)(int));
void pni_raw_async_disconnect(pn_raw_connection_t *conn);
bool pni_raw_can_read(pn_raw_connection_t *conn);
Expand Down
5 changes: 3 additions & 2 deletions c/src/proactor/raw_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void pni_raw_read(pn_raw_connection_t *conn, int sock, long (*recv)(int, void*,
return;
}

void pni_raw_write(pn_raw_connection_t *conn, int sock, long (*send)(int, const void*, size_t), void(*set_error)(pn_raw_connection_t *, const char *, int)) {
void pni_raw_write(pn_raw_connection_t *conn, int sock, long (*send)(int, const void*, size_t, bool), void(*set_error)(pn_raw_connection_t *, const char *, int)) {
assert(conn);

if (pni_raw_wdrained(conn)) return;
Expand All @@ -578,7 +578,8 @@ void pni_raw_write(pn_raw_connection_t *conn, int sock, long (*send)(int, const
assert(conn->wbuffers[p-1].type == buff_unwritten);
char *bytes = conn->wbuffers[p-1].bytes+conn->wbuffers[p-1].offset+conn->unwritten_offset;
size_t s = conn->wbuffers[p-1].size-conn->unwritten_offset;
int r = send(sock, bytes, s);
bool more = conn->wbuffers[p-1].next != 0;
int r = send(sock, bytes, s, more);
if (r < 0) {
// Interrupted system call try again
switch (errno) {
Expand Down
8 changes: 5 additions & 3 deletions c/tests/raw_connection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ namespace {
::shutdown(fd, SHUT_WR);
}

long snd(int fd, const void* b, size_t s) {
long snd(int fd, const void* b, size_t s, bool more) {
write_err = 0;
int flags = MSG_NOSIGNAL | MSG_DONTWAIT;
if (more) flags |= MSG_MORE;
if (max_send_size && max_send_size < s) s = max_send_size;
return ::send(fd, b, s, MSG_NOSIGNAL | MSG_DONTWAIT);
return ::send(fd, b, s, flags);
}

int makepair(int fds[2]) {
Expand Down Expand Up @@ -164,7 +166,7 @@ namespace {
return s;
}

long snd(int fd, const void* b, size_t s){
long snd(int fd, const void* b, size_t s, bool /* more: unused */ ){
CHECK(fd < buffers.size());
write_err = 0;
if (max_send_size && max_send_size < s) s = max_send_size;
Expand Down
Loading