VERBOSE (morep, TRACE, PRINTF ("find_unused_morep\n"));
for (int i = 0; i < MAX_MOREP_NUMBER; i++) {
- // FIXIT: not thread safe
+#if 0
+ i// FIXIT: not thread safe
if (MOREP_list[i]->sock < 0) {
MOREP_list[i]->sock = sock;
+#else
+ if (__sync_bool_compare_and_swap (&MOREP_list[i]->sock, -1, sock)) {
+#endif
VERBOSE (morep, DEBUG, PRINTF ("find morep: %d\n", i));
return i;
}
memcpy (MOREP_list[index]->tx_buffer + 6, sock_addr.sll_addr, 6);
MOREP_list[index]->n_etype = htons (addr.ether_type);
memcpy (MOREP_list[index]->tx_buffer + 12, (void *) &(MOREP_list[index]->n_etype), 2);
+ } else {
+ close (sock);
+ VERBOSE (morep, ERROR, PRINTF ("can't store MOREP for socket %d\n", sock));
+ return -1;
}
return sock;