73
73
#include "plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xcom_cfg.h"
74
74
75
75
#ifndef _WIN32
76
- #ifndef USE_SELECT
77
76
#include <poll.h>
78
77
#endif
79
- #endif
80
78
81
79
#include "plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/retry.h"
82
80
#include "plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/xdr_utils.h"
@@ -88,15 +86,6 @@ task_arg null_arg = {a_end, {0}};
88
86
struct iotasks ;
89
87
typedef struct iotasks iotasks ;
90
88
91
- #ifdef USE_SELECT
92
- struct iotasks {
93
- int maxfd ;
94
- fd_set read_set ;
95
- fd_set write_set ;
96
- fd_set err_set ;
97
- linkage tasks ; /* OHKFIX Should be one each for read and write */
98
- };
99
- #else
100
89
typedef struct {
101
90
u_int pollfd_array_len ;
102
91
pollfd * pollfd_array_val ;
@@ -117,7 +106,7 @@ struct iotasks {
117
106
pollfd_array fd ;
118
107
task_env_p_array tasks ;
119
108
};
120
- #endif
109
+
121
110
int task_errno = 0 ;
122
111
static task_env * extract_first_delayed ();
123
112
static task_env * task_ref (task_env * t );
@@ -593,149 +582,7 @@ static task_env *extract_first_delayed() {
593
582
}
594
583
595
584
static iotasks iot ;
596
- #ifdef USE_SELECT
597
- static void iotasks_init (iotasks * iot ) {
598
- iot -> maxfd = 0 ;
599
- FD_ZERO (& iot -> read_set );
600
- FD_ZERO (& iot -> write_set );
601
- FD_ZERO (& iot -> err_set );
602
- link_init (& iot -> tasks , type_hash ("task_env" ));
603
- }
604
-
605
- static void iotasks_deinit (iotasks * iot )
606
- {
607
- DBGOUT (FN );
608
- }
609
-
610
- #if TASK_DBUG_ON
611
- static void poll_debug () MY_ATTRIBUTE ((unused ));
612
- static void poll_debug () {
613
- GET_GOUT ;
614
- if (!IS_XCOM_DEBUG_WITH (XCOM_DEBUG_TRACE ))
615
- return ;
616
- #if 0
617
- NDBG (FD_SETSIZE , d );
618
- PTREXP (& iot .tasks );
619
- NDBG (iot .tasks .type , u );
620
- NDBG (cardinal (& iot .tasks ), d );
621
- PTREXP (iot .tasks .suc );
622
- PTREXP (iot .tasks .pred );
623
- #endif
624
- FWD_ITER (& iot .tasks , task_env , STRLIT ("->" ); PTREXP (link_iter );
625
- PTREXP (link_iter -> l .suc ); PTREXP (link_iter -> l .pred );
626
- NDBG (link_iter -> waitfd , d );
627
- NDBG (FD_ISSET (link_iter -> waitfd , & iot .read_set ), d );
628
- NDBG (FD_ISSET (link_iter -> waitfd , & iot .write_set ), d );
629
- NDBG (FD_ISSET (link_iter -> waitfd , & iot .err_set ), d ););
630
- PRINT_GOUT ;
631
- FREE_GOUT ;
632
- }
633
- #endif
634
-
635
- static int check_completion (task_env * t , fd_set * r , fd_set * w , fd_set * e ) {
636
- int interrupt = 0 ;
637
- assert (& t -> l != & iot .tasks );
638
- /* MAY_DBG(FN;
639
- STREXP(t->name);
640
- NDBG(t->waitfd,d);
641
- NDBG(FD_ISSET(t->waitfd,r),d);
642
- NDBG(FD_ISSET(t->waitfd,w),d);
643
- NDBG(FD_ISSET(t->waitfd,e),d);
644
- ); */
645
- if (FD_ISSET (t -> waitfd , e )) abort (); /* Close file here instead? */
646
- interrupt = (t -> time != 0.0 && t -> time < task_now ());
647
- if (interrupt || /* timeout ? */
648
- FD_ISSET (t -> waitfd , r ) || FD_ISSET (t -> waitfd , w )) {
649
- FD_CLR (t -> waitfd , & iot .read_set );
650
- FD_CLR (t -> waitfd , & iot .write_set );
651
- FD_CLR (t -> waitfd , & iot .err_set );
652
- t -> interrupt = interrupt ;
653
- activate (t );
654
- if (iot .maxfd - 1 == t -> waitfd )
655
- iot .maxfd = t -> waitfd ; /* Shrink set of watched files */
656
- return 1 ;
657
- } else {
658
- return 0 ;
659
- }
660
- }
661
-
662
- static int poll_wait (int ms ) {
663
- /* Wait at most ms milliseconds */
664
- int wake = 0 ;
665
- struct timeval select_timeout ;
666
- MAY_DBG (FN ; NDBG (ms , d ));
667
- if (ms < 0 || ms > 1000 ) ms = 1000 ; /* Wait at most 1000 ms */
668
- /* convert milliseconds to seconds and microseconds */
669
- select_timeout .tv_sec = ms / 1000 ;
670
- select_timeout .tv_usec = (ms % 1000 ) * 1000 ;
671
- {
672
- result nfds = {0 , 0 };
673
- fd_set r = iot .read_set ;
674
- fd_set w = iot .write_set ;
675
- fd_set e = iot .err_set ;
676
- MAY_DBG (FN ; poll_debug ());
677
- SET_OS_ERR (0 );
678
- while ((nfds .val = select (iot .maxfd , & r , & w , & e , & select_timeout )) == -1 ) {
679
- nfds .funerr = to_errno (GET_OS_ERR );
680
- if (hard_select_err (nfds .funerr )) {
681
- task_dump_err (nfds .funerr );
682
- DBGOUT (STRLIT ("select failed" ); NDBG (iot .maxfd , d ));
683
- return 0 ;
684
- }
685
- SET_OS_ERR (0 );
686
- r = iot .read_set ;
687
- w = iot .write_set ;
688
- e = iot .err_set ;
689
- }
690
- /* MAY_DBG(FN; poll_debug()); */
691
- /* Wake up ready tasks */
692
- /* if (nfds.val > 0) { */
693
- /* FWD_ITER(&iot.tasks, task_env, */
694
- /* nfds.val -= check_completion(link_iter, &r, &w, &e); */
695
- /* if (nfds.val == 0) break); */
696
- /* } */
697
- FWD_ITER (& iot .tasks , task_env ,
698
- if (check_completion (link_iter , & r , & w , & e )) wake = 1 );
699
- }
700
- return wake ;
701
- }
702
585
703
- static void add_fd (task_env * t , int fd , int op ) {
704
- MAY_DBG (FN ; PTREXP (t ); STREXP (t -> name ); NDBG (fd , d ); NDBG (op , c ));
705
- assert (fd >= 0 );
706
- t -> waitfd = fd ;
707
- if (fd >= iot .maxfd ) iot .maxfd = fd + 1 ;
708
- FD_CLR (fd , & iot .err_set );
709
- if ('r' == op )
710
- FD_SET (fd , & iot .read_set );
711
- else
712
- FD_SET (fd , & iot .write_set );
713
- task_wait (t , & iot .tasks );
714
- /* MAY_DBG(FN; poll_debug()); */
715
- }
716
-
717
- static void unpoll (int i ) {
718
- FD_CLR (i , & iot .read_set );
719
- FD_CLR (i , & iot .write_set );
720
- FD_CLR (i , & iot .err_set );
721
- }
722
-
723
- static void wake_all_io () {
724
- FWD_ITER (& iot .tasks , task_env , unpoll (link_iter -> waitfd );
725
- activate (link_iter ););
726
- }
727
-
728
- void remove_and_wakeup (int fd ) {
729
- MAY_DBG (FN ; NDBG (fd , d ));
730
- FWD_ITER (& iot .tasks , task_env , if (fd == link_iter -> waitfd ) {
731
- unpoll (link_iter -> waitfd );
732
- activate (link_iter );
733
- if (iot .maxfd - 1 == link_iter -> waitfd )
734
- iot .maxfd = link_iter -> waitfd ; /* Shrink set of watched files */
735
- });
736
- }
737
-
738
- #else
739
586
static void iotasks_init (iotasks * iot )
740
587
{
741
588
DBGOUT (FN );
@@ -864,7 +711,6 @@ void remove_and_wakeup(int fd) {
864
711
}
865
712
}
866
713
867
- #endif
868
714
task_env * stack = NULL ;
869
715
870
716
task_env * wait_io (task_env * t , int fd , int op ) {
@@ -1131,13 +977,8 @@ void task_loop() {
1131
977
Wait until something happens.
1132
978
*/
1133
979
#ifdef DEBUG_TASKS
1134
- #ifdef USE_SELECT
1135
- MAY_DBG (FN ; STRLIT ("waiting tasks time " ); NDBG (seconds (), f );
1136
- NDBG (cardinal (& iot .tasks ), d ); NDBG (task_time_q .curn , d ));
1137
- #else
1138
980
MAY_DBG (FN ; STRLIT ("waiting tasks time " ); NDBG (seconds (), f );
1139
981
NDBG (iot .nwait , d ); NDBG (task_time_q .curn ));
1140
- #endif
1141
982
#endif
1142
983
{
1143
984
double time = seconds ();
0 commit comments