Skip to content

Commit

Permalink
Attempts to fix netw transmits
Browse files Browse the repository at this point in the history
  • Loading branch information
DasVinch committed Oct 1, 2024
1 parent ec4d7ff commit 4006d03
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 24 deletions.
44 changes: 23 additions & 21 deletions src/COREMOD_memory/stream_TCP.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,27 @@ errno_t COREMOD_MEMORY_testfunction_semaphore(const char *IDname,
switch(errno)
{

case EINTR:
printf(
" sem_wait call was interrupted by a signal "
"handler\n");
break;

case EINVAL:
printf(" not a valid semaphore\n");
break;

case EAGAIN:
printf(
" The operation could not be performed "
"without blocking (i.e., the semaphore "
"currently has "
"the value zero)\n");
break;

default:
printf(" ERROR: unknown code %d\n", rv);
break;
case EINTR:
printf(
" sem_wait call was interrupted by a signal "
"handler\n");
break;

case EINVAL:
printf(" not a valid semaphore\n");
break;

case EAGAIN:
printf(
" The operation could not be performed "
"without blocking (i.e., the semaphore "
"currently has "
"the value zero)\n");
break;

default:
printf(" ERROR: unknown code %d\n", rv);
break;
}
}
else
Expand Down Expand Up @@ -1090,6 +1090,8 @@ imageID COREMOD_MEMORY_image_NETWORKreceive(int port,

monitorindex++;

// Carry cnt0 to streamproctrace
img_p->streamproctrace[0].cnt0 = img_p->md->cnt0;
processinfo_update_output_stream(processinfo, ID);
}

Expand Down
25 changes: 22 additions & 3 deletions src/COREMOD_memory/stream_UDP.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ imageID COREMOD_MEMORY_image_NETUDPreceive(
char *buff; // socket-side complete buffer
char *buff_udp; // socket-side datagram buffer
buff_udp = (char *) malloc(sizeof(char) * DGRAM_CHUNK_SIZE + 2);
char *bigbuff_1MB; // socket-side datagram buffer
bigbuff_1MB = (char *) malloc(sizeof(char) * 1024 * 1024);

// Datagrams
long n_udp_dgrams;
Expand Down Expand Up @@ -793,6 +795,13 @@ imageID COREMOD_MEMORY_image_NETUDPreceive(
n_udp_dgrams = framesizefull / DGRAM_CHUNK_SIZE + 1;
last_dgram_chunk = framesizefull % DGRAM_CHUNK_SIZE;

{
int total_udp_size = 3 * ((n_udp_dgrams - 1) * (DGRAM_CHUNK_SIZE + 2) +
last_dgram_chunk + 2);
setsockopt(fds_server, SOL_SOCKET, SO_SNDBUF, &total_udp_size,
sizeof(total_udp_size));
}

if(data.processinfo == 1)
{
//notify processinfo that we are entering loop
Expand Down Expand Up @@ -850,8 +859,13 @@ imageID COREMOD_MEMORY_image_NETUDPreceive(
// Purge buffer and resync to a 0-th datagram if necessary
// This while will terminate when MSG_DONTWAIT causes a
// errno = EAGAIN / EWOULDBLOCK, meaning the queue is empty.
while(recvfrom(fds_server, buff_udp, first_dgram_bytes, MSG_DONTWAIT,
(struct sockaddr *)&sock_client, &slen_client) >= 0) {}
int sz;
while((sz = recvfrom(fds_server, bigbuff_1MB, 1024 * 1024, MSG_DONTWAIT,
(struct sockaddr *)&sock_client, &slen_client)) >= 0)
{
printf("Urrrrgh. -- %d\n", sz);
fflush(stdout);
}
// Now give ourselves a chance to grab a clean 0-th datagram.
for(int n_dgram_wait = 0; n_dgram_wait < MAX_DATAGRAM_WAIT; ++n_dgram_wait)
{
Expand All @@ -862,7 +876,7 @@ imageID COREMOD_MEMORY_image_NETUDPreceive(
printf("ERROR recvfrom() @ A [%d - %s]\n", errno, strerror(errno));
loopOK = 0;
socketOpen = 0;
break; // This should be a double break...
break; // This should be a double break... loopOK = 0 should cover.
}


Expand All @@ -872,6 +886,11 @@ imageID COREMOD_MEMORY_image_NETUDPreceive(
abort_frame = 0;
break;
}
else
{
printf("MMMMMMhhhhhh.\n");
fflush(stdout);
}
}

}
Expand Down

0 comments on commit 4006d03

Please sign in to comment.