Skip to content

Commit

Permalink
Tidy up tag accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Jun 15, 2024
1 parent 87ef4cc commit 52c6c53
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 251 deletions.
1 change: 1 addition & 0 deletions Inc/uicolours_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define C_VERB_INFO C_LCYAN /* Verbal level info */
#define C_VERB_DEBUG C_LGREEN /* Verbal level debug */
#define C_DATA C_YELLOW /* Output data value */
#define C_NOCHAN C_LRED /* No consumer set for channel */
#define C_DEFAULT C_WHITE

#define C_SEL C_LCYAN /* Element selection */
Expand Down
57 changes: 30 additions & 27 deletions Src/nwclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,40 +212,43 @@ void nwclientSend( struct nwclientsHandle *h, uint32_t len, const uint8_t *ipbuf
{
const struct timespec ts = {.tv_sec = 1, .tv_nsec = 0};

if ( _lock_with_timeout( &h->clientList, &ts ) < 0 )
{
genericsExit( -1, "Failed to acquire mutex" EOL );
}

/* Now kick all the clients that new data arrived for them to distribute */
volatile struct nwClient *n = h->firstClient;

while ( n )
if ( h && h->firstClient )
{
ssize_t t = len;
ssize_t sent = 0;
void *p = ( void * )ipbuffer;

while ( t && ( sent >= 0 ) )
if ( _lock_with_timeout( &h->clientList, &ts ) < 0 )
{
sent = send( n->portNo, p, t, MSG_NOSIGNAL );
p += sent;
t -= sent;
genericsExit( -1, "Failed to acquire mutex" EOL );
}

if ( t )
{
volatile struct nwClient *newn = n->nextClient;
_clientRemoveNoLock( n );
n = newn;
}
else
/* Now kick all the clients that new data arrived for them to distribute */
volatile struct nwClient *n = h->firstClient;

while ( n )
{
n = n->nextClient;
ssize_t t = len;
ssize_t sent = 0;
void *p = ( void * )ipbuffer;

while ( t && ( sent >= 0 ) )
{
sent = send( n->portNo, p, t, MSG_NOSIGNAL );
p += sent;
t -= sent;
}

if ( t )
{
volatile struct nwClient *newn = n->nextClient;
_clientRemoveNoLock( n );
n = newn;
}
else
{
n = n->nextClient;
}
}
}

pthread_mutex_unlock( &h->clientList );
pthread_mutex_unlock( &h->clientList );
}
}
// ====================================================================================================
struct nwclientsHandle *nwclientStart( int port )
Expand Down
Loading

0 comments on commit 52c6c53

Please sign in to comment.