Previous 199869 Revisions Next

r40663 Thursday 10th September, 2015 at 13:19:54 UTC by R. Belmont
netdev: fix pcap crashes on OS X [Rob Braun]
[src/osd/modules/netdev]pcap.c

trunk/src/osd/modules/netdev/pcap.c
r249174r249175
125125static void netdev_pcap_handler(u_char *user, const struct pcap_pkthdr *h, const u_char *bytes) {
126126   struct netdev_pcap_context *ctx = (struct netdev_pcap_context*)user;
127127
128   if(!ctx->p) return;
129
128130   if(OSAtomicCompareAndSwapInt((ctx->head+1) & 0x1F, ctx->tail, &ctx->tail)) {
129131      printf("buffer full, dropping packet\n");
130132      return;
r249174r249175
137139static void *netdev_pcap_blocker(void *arg) {
138140   struct netdev_pcap_context *ctx = (struct netdev_pcap_context*)arg;
139141
140   while(1) {
142   while(ctx && ctx->p) {
141143      pcap_dispatch_dl(ctx->p, 1, netdev_pcap_handler, (u_char*)ctx);
142144   }
143145
r249174r249175
232234
233235netdev_pcap::~netdev_pcap()
234236{
237#ifdef SDLMAME_MACOSX
238   m_ctx.p = NULL;
239   pthread_cancel(m_thread);
240   pthread_join(m_thread, NULL);
241#endif
235242   if(m_p) pcap_close_dl(m_p);
236243   m_p = NULL;
237244}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team