aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NOTES.txt6
-rw-r--r--README.txt7
-rw-r--r--iemnet_receiver.c14
-rw-r--r--iemnet_sender.c4
-rw-r--r--udpserver.c28
5 files changed, 28 insertions, 31 deletions
diff --git a/NOTES.txt b/NOTES.txt
index 1a4f2d2..da5ee7a 100644
--- a/NOTES.txt
+++ b/NOTES.txt
@@ -3,13 +3,13 @@ scratchpad for the development of iemnet
speed & syslocks
================
-one bottleneck right now is the synchronisation with Pd's
+one bottleneck right now is the synchronisation with Pd's
main thread to register a clock callback.
doing a sys_lock() whenever a package arrives will slow down things immensely.
alternatives:
no sys_lock(): will eventually crash Pd (no option)
- use sys_trylock(): this might eventually fail to notify Pd of newly arrived
+ use sys_trylock(): this might eventually fail to notify Pd of newly arrived
packets (bad for throughput)
external polling: no syslock needed at all, but more complicated
keep track of clock_callback: "notified" flag tells us, whether we have already
@@ -23,4 +23,4 @@ tests for tcpclient/server:
server disconnects -> client should get notified
client crashes -> server should disconnect
server crashes -> client should disconnect
-
+
diff --git a/README.txt b/README.txt
index 191818a..385578e 100644
--- a/README.txt
+++ b/README.txt
@@ -25,9 +25,8 @@ time), easy DoS (each thread uses one in a limited number of thread handles),
and abandons determinism (nobody guarantees that parallel threads are executed
"in order"; thus a message in a later-spawned thread might be delivered to the
socket earlier than older messages - effectively circumventing one of the
-promises of TCP/IP: that all packets will reappear in order; i haven't seen this
-behaviour of mrpeach/net in real life yet; however i don't see any
-countermeasurements either)
+promises of TCP/IP: that all packets will reappear in order; users have already
+reported this behaviour, which makes using those objects a bit unreliable)
on the long run compatibility with the upstream library is intended.
(though probably not for all the cruft that is in there)
@@ -51,7 +50,7 @@ _heavy_ load. most do both.
iemnet wants to provide objects whih allow you to saturate the network
connection and still keep Pd reactive.
(sidenote: saturating even a 100MBit network with Pd might lead to audio
-dropouts; this is not necessarily related to the network but rather to the
+dropouts; this is not necessarily related to the network but rather to the
amount of data processed by Pd...)
easy to use:
diff --git a/iemnet_receiver.c b/iemnet_receiver.c
index f1d2277..1b4f00f 100644
--- a/iemnet_receiver.c
+++ b/iemnet_receiver.c
@@ -47,7 +47,6 @@ struct _iemnet_receiver {
t_iemnet_queue*queue;
t_clock *clock;
-
int newdataflag;
int running;
int keepreceiving;
@@ -156,14 +155,14 @@ static void*iemnet__receiver_readthread(void*arg) {
//fprintf(stderr, "read %d bytes...\n", result);
DEBUG("recfrom %d bytes: %p", result, data);
c= iemnet__chunk_create_dataaddr(result, (result>0)?data:NULL, &from);
- DEBUG("pushing");
+ DEBUG("pushing");
queue_push(q, c);
- DEBUG("signalling");
+ DEBUG("signalling");
iemnet_signalNewData(receiver);
if(result<=0) break;
- DEBUG("rereceive");
+ DEBUG("rereceive");
}
// oha
DEBUG("readthread loop termination: %d", result);
@@ -207,7 +206,7 @@ static void iemnet__receiver_tick(t_iemnet_receiver *x)
pthread_mutex_unlock(&x->keeprec_mtx);
/* keepreceiving is set, if receiver is not yet in shutdown mode */
- if(keepreceiving)
+ if(keepreceiving)
x->callback(x->userdata, NULL);
}
DEBUG("tick DONE");
@@ -291,7 +290,6 @@ void iemnet__receiver_destroy(t_iemnet_receiver*rec) {
sockfd=rec->sockfd;
- DEBUG("joining thread");
pthread_join(rec->recthread, NULL);
pthread_cond_signal(&rec->newdata_cond);
@@ -305,7 +303,7 @@ void iemnet__receiver_destroy(t_iemnet_receiver*rec) {
*/
shutdown(sockfd, 2); /* needed on linux, since the recv won't shutdown on sys_closesocket() alone */
- sys_closesocket(sockfd);
+ sys_closesocket(sockfd);
}
DEBUG("[%d] closed socket %d", inst, sockfd);
@@ -314,7 +312,7 @@ void iemnet__receiver_destroy(t_iemnet_receiver*rec) {
// empty the queue
DEBUG("[%d] tick %d", inst, rec->running);
iemnet__receiver_tick(rec);
- queue_destroy(rec->queue);
+ queue_destroy(rec->queue);
DEBUG("[%d] tack", inst);
if(rec->data)iemnet__chunk_destroy(rec->data);
diff --git a/iemnet_sender.c b/iemnet_sender.c
index b84d8ce..0e4f866 100644
--- a/iemnet_sender.c
+++ b/iemnet_sender.c
@@ -47,8 +47,8 @@
#if IEMNET_HAVE_DEBUG
static int debug_lockcount=0;
-# define LOCK(x) do {pthread_mutex_lock(x);debug_lockcount++; if(debuglevel&DEBUGLEVEL)post(" LOCK %d (@%s:%d)", debug_lockcount, __FILE__, __LINE__); } while(0)
-# define UNLOCK(x) do {debug_lockcount--;if(debuglevel&DEBUGLEVEL)post("UNLOCK %d (@%s:%d)", debug_lockcount, __FILE__, __LINE__);pthread_mutex_unlock(x);}while(0)
+# define LOCK(x) do {if(iemnet_debug(DEBUGLEVEL, __FILE__, __LINE__, __FUNCTION__))post(" LOCKing %p", x); pthread_mutex_lock(x);debug_lockcount++; if(iemnet_debug(DEBUGLEVEL, __FILE__, __LINE__, __FUNCTION__))post(" LOCKed %p[%d]", x, debug_lockcount); } while(0)
+# define UNLOCK(x) do {debug_lockcount--;if(iemnet_debug(DEBUGLEVEL, __FILE__, __LINE__, __FUNCTION__))post(" UNLOCK %p [%d]", x, debug_lockcount); pthread_mutex_unlock(x);}while(0)
#else
# define LOCK(x) pthread_mutex_lock(x)
# define UNLOCK(x) pthread_mutex_unlock(x)
diff --git a/udpserver.c b/udpserver.c
index 1f17150..37e2ad7 100644
--- a/udpserver.c
+++ b/udpserver.c
@@ -57,7 +57,7 @@ typedef struct _udpserver
t_outlet *x_connectout;
t_outlet *x_sockout; // legacy
t_outlet *x_addrout; // legacy
- t_outlet *x_statout;
+ t_outlet *x_statout;
t_udpserver_sender *x_sr[MAX_CONNECT]; /* socket per connection */
t_int x_nconnections;
@@ -127,7 +127,7 @@ static int udpserver_socket2index(t_udpserver*x, int sockfd)
{
return i;
}
- }
+ }
return -1;
}
@@ -142,7 +142,7 @@ static int udpserver_fixindex(t_udpserver*x, int client)
pd_error(x, "[%s]: no clients connected", objName);
return -1;
}
-
+
if (!((client > 0) && (client <= x->x_nconnections)))
{
pd_error(x, "[%s] client %d out of range [1..%d]", objName, client, (int)(x->x_nconnections));
@@ -155,7 +155,7 @@ static int udpserver_fixindex(t_udpserver*x, int client)
/* returns 1 if addr1==addr2, 0 otherwise */
static int equal_addr(unsigned long host1, unsigned short port1, unsigned long host2, unsigned short port2) {
return (
- ((port1 == port2) &&
+ ((port1 == port2) &&
(host1 == host2))
);
}
@@ -174,7 +174,7 @@ static int udpserver__find_sender(t_udpserver*x, unsigned long host, unsigned s
* check whether the sender is already registered
* if not, add it to the list of registered senders
*/
-static t_udpserver_sender* udpserver_sender_add(t_udpserver*x,
+static t_udpserver_sender* udpserver_sender_add(t_udpserver*x,
unsigned long host, unsigned short port )
{
int id=-1;
@@ -186,7 +186,7 @@ static t_udpserver_sender* udpserver_sender_add(t_udpserver*x,
if(id<0) {
#if 1
/* since udp is a connection-less protocol we have no way of knowing the currently connected clients
- * the following 3 lines assume, that there is only one client connected (the last we got data from
+ * the following 3 lines assume, that there is only one client connected (the last we got data from
*/
id=0;
udpserver_sender_free(x->x_sr[id]);
@@ -252,7 +252,7 @@ static void udpserver_info_client(t_udpserver *x, int client)
int insize =iemnet__receiver_getsize(x->x_receiver);
int outsize=iemnet__sender_getsize (x->x_sr[client]->sr_sender );
- snprintf(hostname, MAXPDSTRING-1, "%d.%d.%d.%d",
+ snprintf(hostname, MAXPDSTRING-1, "%d.%d.%d.%d",
(unsigned char)((address & 0xFF000000)>>24),
(unsigned char)((address & 0x0FF0000)>>16),
(unsigned char)((address & 0x0FF00)>>8),
@@ -374,7 +374,7 @@ static void udpserver_send_toclient(t_udpserver *x, int client, int argc, t_atom
static void udpserver_send_client(t_udpserver *x, t_symbol *s, int argc, t_atom *argv)
{
int client=0;
-
+
if (argc > 0)
{
client=udpserver_fixindex(x, atom_getint(argv));
@@ -386,7 +386,7 @@ static void udpserver_send_client(t_udpserver *x, t_symbol *s, int argc, t_atom
}
return;
}
- else
+ else
{
for(client=0; client<x->x_nconnections; client++)
udpserver_info_client(x, client);
@@ -427,14 +427,14 @@ static void udpserver_defaultsend(t_udpserver *x, t_symbol *s, int argc, t_atom
int client=-1;
int sockfd=x->x_defaulttarget;
DEBUG("sending to sockfd: %d", sockfd);
- if(0==sockfd)
+ if(0==sockfd)
udpserver_broadcast(x, s, argc, argv);
else if(sockfd>0) {
client=udpserver_socket2index(x, sockfd);
udpserver_send_toclient(x, client, argc, argv);
} else if(sockfd<0) {
client=udpserver_socket2index(x, -sockfd);
- udpserver_send_butclient(x, client, argc, argv);
+ udpserver_send_butclient(x, client, argc, argv);
}
}
static void udpserver_defaulttarget(t_udpserver *x, t_floatarg f)
@@ -453,7 +453,7 @@ static void udpserver_defaulttarget(t_udpserver *x, t_floatarg f)
sockfd=x->x_sr[client-1]->sr_fd;
}
- if(rawclient<0)sockfd=-sockfd;
+ if(rawclient<0)sockfd=-sockfd;
x->x_defaulttarget=sockfd;
}
@@ -494,7 +494,7 @@ static void udpserver_send_socket(t_udpserver *x, t_symbol *s, int argc, t_atom
error("[%s]: no socket specified", objName);
return;
}
-
+
chunk=iemnet__chunk_create_list(argc-1, argv+1);
udpserver_send_bytes(x, client, chunk);
iemnet__chunk_destroy(chunk);
@@ -659,7 +659,7 @@ static void udpserver_port(t_udpserver*x, t_floatarg fportno)
}
x->x_receiver=iemnet__receiver_create(sockfd,
- x,
+ x,
udpserver_receive_callback);
x->x_connectsocket = sockfd;