1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
|
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
#include "core/nng_impl.h"
#include "platform/posix/posix_aio.h"
#ifdef NNG_USE_POSIX_AIOPOLL
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <unistd.h>
#include <poll.h>
// POSIX AIO using poll(). We use a single poll thread to perform
// I/O operations for the entire system. This isn't entirely scalable,
// and it might be a good idea to create a few threads and group the
// I/O operations into separate pollers to limit the amount of work each
// thread does, and to scale across multiple cores. For now we don't
// worry about it.
typedef struct nni_posix_pollq nni_posix_pollq;
// nni_posix_pipedesc is a descriptor kept one per transport pipe (i.e. open
// file descriptor for TCP socket, etc.) This contains the list of pending
// aios for that underlying socket, as well as the socket itself.
struct nni_posix_pipedesc {
int fd;
int index;
nni_list readq;
nni_list writeq;
nni_list_node node;
nni_posix_pollq * pq;
int nonblocking;
};
struct nni_posix_epdesc {
int fd;
int index;
nni_list connectq;
nni_list acceptq;
nni_list_node node;
nni_posix_pollq * pq;
struct sockaddr_storage locaddr;
struct sockaddr_storage remaddr;
};
// nni_posix_pollq is a work structure used by the poller thread, that keeps
// track of all the underlying pipe handles and so forth being used by poll().
struct nni_posix_pollq {
nni_mtx mtx;
struct pollfd * fds;
struct pollfd * newfds;
int nfds;
int nnewfds;
int wakewfd; // write side of waker pipe
int wakerfd; // read side of waker pipe
int close; // request for worker to exit
int started;
nni_thr thr; // worker thread
nni_list pds; // nni_posix_pipedescs.
int npds; // length of pds list
nni_list eds; // nni_posix_epdescs
int neds; // length of eds list
};
static nni_posix_pollq nni_posix_global_pollq;
static void
nni_posix_epdesc_cancel(nni_aio *aio)
{
nni_posix_epdesc *ed;
nni_posix_pollq *pq;
ed = aio->a_prov_data;
pq = ed->pq;
nni_mtx_lock(&pq->mtx);
// This will remove the aio from either the read or the write
// list; it doesn't matter which.
if (nni_list_active(&ed->connectq, aio)) {
nni_list_remove(&ed->connectq, aio);
}
nni_mtx_unlock(&pq->mtx);
}
static void
nni_posix_epdesc_finish(nni_aio *aio, int rv, int newfd)
{
nni_posix_epdesc *ed;
ed = aio->a_prov_data;
if (nni_list_active(&ed->connectq, aio)) {
nni_list_remove(&ed->connectq, aio);
}
// Abuse the count to hold our new fd. This is only for accept.
nni_aio_finish(aio, rv, newfd);
}
static void
nni_posix_poll_connect(nni_posix_epdesc *ed)
{
nni_aio *aio;
socklen_t sz;
int rv;
// Note that normally there will only be a single connect AIO...
// A socket that is here will have *initiated* with a connect()
// call, which returned EINPROGRESS. When the connection attempt
// is done, either way, the descriptor will be noted as writable.
// getsockopt() with SOL_SOCKET, SO_ERROR to determine the actual
// status of the connection attempt...
while ((aio = nni_list_first(&ed->connectq)) != NULL) {
rv = -1;
sz = sizeof (rv);
if (getsockopt(ed->fd, SOL_SOCKET, SO_ERROR, &rv, &sz) < 0) {
nni_posix_epdesc_finish(aio,
nni_plat_errno(errno), 0);
continue;
}
switch (rv) {
case 0:
// Success!
nni_posix_epdesc_finish(aio, 0, 0);
continue;
case EINPROGRESS:
// Still in progress... keep trying
return;
default:
nni_posix_epdesc_finish(aio, nni_plat_errno(rv), 0);
continue;
}
}
}
static void
nni_posix_poll_accept(nni_posix_epdesc *ed)
{
nni_aio *aio;
int newfd;
struct sockaddr_storage ss;
socklen_t slen;
while ((aio = nni_list_first(&ed->acceptq)) != NULL) {
// We could argue that knowing the remote peer address would
// be nice. But frankly if someone wants it, they can just
// do getpeername().
#ifdef NNG_USE_ACCEPT4
newfd = accept4(ed->fd, NULL, NULL, SOCK_CLOEXEC);
if ((newfd < 0) &&
((errno == ENOSYS) || (errno == ENOTSUP))) {
newfd = accept(ed->fd, NULL, NULL);
}
#else
newfd = accept(ed->fd, NULL, NULL);
#endif
if (newfd >= 0) {
// successful connection request!
nni_posix_epdesc_finish(aio, 0, newfd);
continue;
}
if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) {
// Well, let's try later. Note that EWOULDBLOCK
// is required by standards, but some platforms may
// use EAGAIN. The values may be the same, so we
// can't use switch.
return;
}
if (errno == ECONNABORTED) {
// Let's just eat this one. Perhaps it may be
// better to report it to the application, but we
// think most applications don't want to see this.
// Only someone with a packet trace is going to
// notice this.
continue;
}
nni_posix_epdesc_finish(aio, nni_plat_errno(errno), 0);
}
}
static void
nni_posix_poll_epclose(nni_posix_epdesc *ed)
{
nni_aio *aio;
while ((aio = nni_list_first(&ed->acceptq)) != NULL) {
nni_posix_epdesc_finish(aio, NNG_ECLOSED, 0);
}
while ((aio = nni_list_first(&ed->connectq)) != NULL) {
nni_posix_epdesc_finish(aio, NNG_ECLOSED, 0);
}
}
static void
nni_posix_pipedesc_finish(nni_aio *aio, int rv)
{
nni_posix_pipedesc *pd;
pd = aio->a_prov_data;
if (nni_list_active(&pd->readq, aio)) {
nni_list_remove(&pd->readq, aio);
}
nni_aio_finish(aio, rv, aio->a_count);
}
static void
nni_posix_poll_write(nni_posix_pipedesc *pd)
{
int n;
int rv;
int i;
struct iovec iovec[4];
struct iovec *iovp;
nni_aio *aio;
while ((aio = nni_list_first(&pd->writeq)) != NULL) {
for (i = 0; i < aio->a_niov; i++) {
iovec[i].iov_len = aio->a_iov[i].iov_len;
iovec[i].iov_base = aio->a_iov[i].iov_buf;
}
iovp = &iovec[0];
rv = 0;
n = writev(pd->fd, iovp, aio->a_niov);
if (n < 0) {
if ((errno == EAGAIN) || (errno == EINTR)) {
// Can't write more right now. We're done
// on this fd for now.
return;
}
rv = nni_plat_errno(errno);
nni_posix_pipedesc_finish(aio, rv);
return;
}
aio->a_count += n;
while (n > 0) {
// If we didn't write the first full iov,
// then we're done for now. Record progress
// and return to caller.
if (n < aio->a_iov[0].iov_len) {
aio->a_iov[0].iov_buf += n;
aio->a_iov[0].iov_len -= n;
return;
}
// We consumed the full iovec, so just move the
// remaininng ones up, and decrement count handled.
n -= aio->a_iov[0].iov_len;
for (i = 1; i < aio->a_niov; i++) {
aio->a_iov[i-1] = aio->a_iov[i];
}
NNI_ASSERT(aio->a_niov > 0);
aio->a_niov--;
}
// We completed the entire operation on this aioq.
nni_list_remove(&pd->writeq, aio);
nni_posix_pipedesc_finish(aio, 0);
// Go back to start of loop to see if there is another
// aioq ready for us to process.
}
}
static void
nni_posix_poll_read(nni_posix_pipedesc *pd)
{
int n;
int rv;
int i;
struct iovec iovec[4];
struct iovec *iovp;
nni_aio *aio;
while ((aio = nni_list_first(&pd->readq)) != NULL) {
for (i = 0; i < aio->a_niov; i++) {
iovec[i].iov_len = aio->a_iov[i].iov_len;
iovec[i].iov_base = aio->a_iov[i].iov_buf;
}
iovp = &iovec[0];
rv = 0;
n = readv(pd->fd, iovp, aio->a_niov);
if (n < 0) {
if ((errno == EAGAIN) || (errno == EINTR)) {
// Can't write more right now. We're done
// on this fd for now.
return;
}
rv = nni_plat_errno(errno);
nni_posix_pipedesc_finish(aio, rv);
return;
}
if (n == 0) {
// No bytes indicates a closed descriptor.
nni_posix_pipedesc_finish(aio, NNG_ECLOSED);
return;
}
aio->a_count += n;
while (n > 0) {
// If we didn't write the first full iov,
// then we're done for now. Record progress
// and return to caller.
if (n < aio->a_iov[0].iov_len) {
aio->a_iov[0].iov_buf += n;
aio->a_iov[0].iov_len -= n;
return;
}
// We consumed the full iovec, so just move the
// remaininng ones up, and decrement count handled.
n -= aio->a_iov[0].iov_len;
for (i = 1; i < aio->a_niov; i++) {
aio->a_iov[i-1] = aio->a_iov[i];
}
NNI_ASSERT(aio->a_niov > 0);
aio->a_niov--;
}
// We completed the entire operation on this aioq.
nni_posix_pipedesc_finish(aio, 0);
// Go back to start of loop to see if there is another
// aioq ready for us to process.
}
}
static void
nni_posix_poll_close(nni_posix_pipedesc *pd)
{
nni_aio *aio;
while ((aio = nni_list_first(&pd->readq)) != NULL) {
nni_posix_pipedesc_finish(aio, NNG_ECLOSED);
}
while ((aio = nni_list_first(&pd->writeq)) != NULL) {
nni_posix_pipedesc_finish(aio, NNG_ECLOSED);
}
}
void
nni_posix_pipedesc_close(nni_posix_pipedesc *pd)
{
nni_posix_pollq *pq;
pq = pd->pq;
nni_mtx_lock(&pq->mtx);
pd->fd = -1;
nni_posix_poll_close(pd);
if (nni_list_active(&pq->pds, pd)) {
nni_list_remove(&pq->pds, pd);
pq->npds--;
}
nni_mtx_unlock(&pq->mtx);
}
static void
nni_posix_poll_thr(void *arg)
{
nni_posix_pollq *pollq = arg;
nni_posix_pipedesc *pd, *nextpd;
nni_posix_epdesc *ed, *nexted;
nni_mtx_lock(&pollq->mtx);
for (;;) {
int rv;
int nfds;
struct pollfd *fds;
if (pollq->close) {
break;
}
if (pollq->newfds != NULL) {
// We have "grown" by the caller. Free up the old
// space, and start using the new.
nni_free(pollq->fds,
pollq->nfds * sizeof (struct pollfd));
pollq->fds = pollq->newfds;
pollq->nfds = pollq->nnewfds;
pollq->newfds = NULL;
}
fds = pollq->fds;
nfds = 0;
// The waker pipe is set up so that we will be woken
// when it is written (this allows us to be signaled).
fds[nfds].fd = pollq->wakerfd;
fds[nfds].events = POLLIN;
fds[nfds].revents = 0;
nfds++;
// Set up the poll list.
NNI_LIST_FOREACH (&pollq->pds, pd) {
fds[nfds].fd = pd->fd;
fds[nfds].events = 0;
fds[nfds].revents = 0;
if (nni_list_first(&pd->readq) != NULL) {
fds[nfds].events |= POLLIN;
}
if (nni_list_first(&pd->writeq) != NULL) {
fds[nfds].events |= POLLOUT;
}
pd->index = nfds;
nfds++;
}
NNI_LIST_FOREACH (&pollq->eds, ed) {
fds[nfds].fd = ed->fd;
fds[nfds].events = 0;
fds[nfds].revents = 0;
if (nni_list_first(&ed->connectq) != NULL) {
fds[nfds].events |= POLLOUT;
}
if (nni_list_first(&ed->acceptq) != NULL) {
fds[nfds].events |= POLLIN;
}
ed->index = nfds;
nfds++;
}
// Now poll it. We block indefinitely, since we use separate
// timeouts to wake and remove the elements from the list.
nni_mtx_unlock(&pollq->mtx);
rv = poll(fds, nfds, -1);
nni_mtx_lock(&pollq->mtx);
if (rv < 0) {
// This shouldn't happen really. If it does, we
// just try again. (EINTR is probably the only
// reasonable failure here, unless internal memory
// allocations fail in the kernel, leading to EAGAIN.)
continue;
}
// If the waker pipe was signaled, read from it.
if (fds[0].revents & POLLIN) {
NNI_ASSERT(fds[0].fd == pollq->wakerfd);
nni_plat_pipe_clear(pollq->wakerfd);
}
// Now we iterate through all the pipedescs. Note that one
// may have been added or removed. New pipedescs will have
// their index set to -1. Removed ones will just be absent.
// Note that we may remove the pipedesc from the list, so we
// have to use a custom iterator.
nextpd = nni_list_first(&pollq->pds);
while ((pd = nextpd) != NULL) {
int index;
// Save the nextpd for our next iteration. This
// way we can remove the PD from the list without
// breaking the iteration.
nextpd = nni_list_next(&pollq->pds, pd);
if ((index = pd->index) < 1) {
continue;
}
pd->index = 0;
if (fds[index].revents & POLLIN) {
// process the read q.
nni_posix_poll_read(pd);
}
if (fds[index].revents & POLLOUT) {
// process the write q.
nni_posix_poll_write(pd);
}
if (fds[index].revents & (POLLHUP|POLLERR|POLLNVAL)) {
// the pipe is closed. wake all the
// aios with NNG_ECLOSED.
nni_posix_poll_close(pd);
}
// If we have completed all the AIOs outstanding,
// then remove this pipedesc from the pollq.
if ((nni_list_first(&pd->readq) == NULL) &&
(nni_list_first(&pd->writeq) == NULL)) {
nni_list_remove(&pollq->pds, pd);
pollq->npds--;
}
}
// Same thing for ep descs.
nexted = nni_list_first(&pollq->eds);
while ((ed = nexted) != NULL) {
int index;
nexted = nni_list_next(&pollq->eds, ed);
if ((index = ed->index) < 1) {
continue;
}
ed->index = 0;
if (fds[index].revents & POLLIN) {
nni_posix_poll_accept(ed);
}
if (fds[index].revents & POLLOUT) {
nni_posix_poll_connect(ed);
}
if (fds[index].revents & (POLLHUP|POLLERR|POLLNVAL)) {
nni_posix_poll_epclose(ed);
}
if ((nni_list_first(&ed->connectq) == NULL) &&
(nni_list_first(&ed->acceptq) == NULL)) {
nni_list_remove(&pollq->eds, ed);
pollq->neds--;
}
}
}
nni_mtx_unlock(&pollq->mtx);
}
static void
nni_posix_pipedesc_cancel(nni_aio *aio)
{
nni_posix_pipedesc *pd;
nni_posix_pollq *pq;
pd = aio->a_prov_data;
pq = pd->pq;
nni_mtx_lock(&pq->mtx);
// This will remove the aio from either the read or the write
// list; it doesn't matter which.
if (nni_list_active(&pd->readq, aio)) {
nni_list_remove(&pd->readq, aio);
}
nni_mtx_unlock(&pq->mtx);
}
static int
nni_posix_poll_grow(nni_posix_pollq *pq)
{
int grow = pq->npds + pq->neds + 2; // one for us, one for waker
int noldfds;
struct pollfd *oldfds;
struct pollfd *newfds;
if ((grow < pq->nfds) || (grow < pq->nnewfds)) {
return (0);
}
grow = grow + 128;
// Maybe we are adding a *lot* of pipes at once, and have to grow
// multiple times before the poller gets scheduled. In that case
// toss the old array before we finish.
oldfds = pq->newfds;
noldfds = pq->nnewfds;
if ((newfds = nni_alloc(grow * sizeof (struct pollfd))) == NULL) {
return (NNG_ENOMEM);
}
pq->newfds = newfds;
pq->nnewfds = grow;
if (noldfds != 0) {
nni_free(oldfds, noldfds * sizeof (struct pollfd));
}
return (0);
}
static void
nni_posix_pipedesc_submit(nni_posix_pipedesc *pd, nni_list *l, nni_aio *aio)
{
int wake;
int rv;
nni_posix_pollq *pq = pd->pq;
nni_mtx_lock(&pq->mtx);
if (pd->fd < 0) {
nni_mtx_unlock(&pq->mtx);
nni_aio_finish(aio, NNG_ECLOSED, aio->a_count);
return;
}
// XXX: We really should just make all the FDs nonblocking, but we
// need to fix the negotiation phase.
if (pd->nonblocking == 0) {
(void) fcntl(pd->fd, F_SETFL, O_NONBLOCK);
pd->nonblocking = 1;
}
if ((rv = nni_aio_start(aio, nni_posix_pipedesc_cancel, pd)) != 0) {
nni_mtx_unlock(&pq->mtx);
return;
}
if (!nni_list_active(&pq->pds, pd)) {
if ((rv = nni_posix_poll_grow(pq)) != 0) {
nni_aio_finish(aio, rv, aio->a_count);
nni_mtx_unlock(&pq->mtx);
return;
}
nni_list_append(&pq->pds, pd);
pq->npds++;
}
NNI_ASSERT(!nni_list_active(l, aio));
// Only wake if we aren't already waiting for this type of I/O on
// this descriptor.
wake = nni_list_first(l) == NULL ? 1 : 0;
nni_list_append(l, aio);
if (wake) {
nni_plat_pipe_raise(pq->wakewfd);
}
nni_mtx_unlock(&pq->mtx);
}
int
nni_posix_pipedesc_init(nni_posix_pipedesc **pdp, int fd)
{
nni_posix_pipedesc *pd;
if ((pd = NNI_ALLOC_STRUCT(pd)) == NULL) {
return (NNG_ENOMEM);
}
// We could randomly choose a different pollq, or for efficiencies
// sake we could take a modulo of the file desc number to choose
// one. For now we just have a global pollq. Note that by tying
// the pd to a single pollq we may get some kind of cache warmth.
pd->pq = &nni_posix_global_pollq;
pd->fd = fd;
pd->index = 0;
pd->nonblocking = 0;
NNI_LIST_INIT(&pd->readq, nni_aio, a_prov_node);
NNI_LIST_INIT(&pd->writeq, nni_aio, a_prov_node);
*pdp = pd;
return (0);
}
void
nni_posix_pipedesc_fini(nni_posix_pipedesc *pd)
{
nni_aio *aio;
nni_posix_pollq *pq = pd->pq;
nni_mtx_lock(&pq->mtx);
// This removes any aios from our list.
nni_posix_poll_close(pd);
if (nni_list_active(&pq->pds, pd)) {
nni_list_remove(&pq->pds, pd);
pq->npds--;
}
nni_mtx_unlock(&pq->mtx);
NNI_FREE_STRUCT(pd);
}
static void
nni_posix_pollq_fini(nni_posix_pollq *pq)
{
if (pq->started) {
nni_mtx_lock(&pq->mtx);
pq->close = 1;
pq->started = 0;
nni_plat_pipe_raise(pq->wakewfd);
// All pipes should have been closed before this is called.
NNI_ASSERT(nni_list_first(&pq->pds) == NULL);
nni_mtx_unlock(&pq->mtx);
}
nni_thr_fini(&pq->thr);
if (pq->wakewfd >= 0) {
nni_plat_pipe_close(pq->wakewfd, pq->wakerfd);
pq->wakewfd = pq->wakerfd = -1;
}
nni_free(pq->newfds, pq->nnewfds * sizeof (struct pollfd));
nni_free(pq->fds, pq->nfds * sizeof (struct pollfd));
nni_mtx_fini(&pq->mtx);
}
static int
nni_posix_pollq_init(nni_posix_pollq *pq)
{
int rv;
NNI_LIST_INIT(&pq->pds, nni_posix_pipedesc, node);
pq->wakewfd = -1;
pq->wakerfd = -1;
pq->close = 0;
if (((rv = nni_mtx_init(&pq->mtx)) != 0) ||
((rv = nni_posix_poll_grow(pq)) != 0) ||
((rv = nni_plat_pipe_open(&pq->wakewfd, &pq->wakerfd)) != 0) ||
((rv = nni_thr_init(&pq->thr, nni_posix_poll_thr, pq)) != 0)) {
nni_posix_pollq_fini(pq);
return (rv);
}
pq->started = 1;
nni_thr_run(&pq->thr);
return (0);
}
int
nni_posix_pipedesc_sysinit(void)
{
int rv;
rv = nni_posix_pollq_init(&nni_posix_global_pollq);
return (rv);
}
void
nni_posix_pipedesc_sysfini(void)
{
nni_posix_pollq_fini(&nni_posix_global_pollq);
}
// extern int nni_posix_aio_ep_init(nni_posix_aio_ep *, int);
// extern void nni_posix_aio_ep_fini(nni_posix_aio_ep *);
void
nni_posix_pipedesc_read(nni_posix_pipedesc *pd, nni_aio *aio)
{
nni_posix_pipedesc_submit(pd, &pd->readq, aio);
}
void
nni_posix_pipedesc_write(nni_posix_pipedesc *pd, nni_aio *aio)
{
nni_posix_pipedesc_submit(pd, &pd->writeq, aio);
}
// extern int nni_posix_aio_connect();
// extern int nni_posix_aio_accept();
#else
// Suppress empty symbols warnings in ranlib.
int nni_posix_poll_not_used = 0;
#endif // NNG_USE_POSIX_AIOPOLL
|