Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 663236
Collapse All | Expand All

(-)mysql-connector-c-6.1.11-src/cmake/os/WindowsCache.cmake (-2 lines)
Lines 159-166 SET(HAVE_LRAND48 CACHE INTERNAL "") Link Here
159
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
159
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
160
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
160
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
161
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
161
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
162
SET(HAVE_SIGEV_THREAD_ID CACHE INTERNAL "")
163
SET(HAVE_SIGEV_PORT CACHE INTERNAL "")
164
# Check needed HAVE_LOG2
162
# Check needed HAVE_LOG2
165
163
166
# Check needed HAVE_ISINF
164
# Check needed HAVE_ISINF
(-)mysql-connector-c-6.1.11-src/config.h.cmake (-2 lines)
Lines 156-163 Link Here
156
#cmakedefine GWINSZ_IN_SYS_IOCTL 1
156
#cmakedefine GWINSZ_IN_SYS_IOCTL 1
157
#cmakedefine FIONREAD_IN_SYS_IOCTL 1
157
#cmakedefine FIONREAD_IN_SYS_IOCTL 1
158
#cmakedefine FIONREAD_IN_SYS_FILIO 1
158
#cmakedefine FIONREAD_IN_SYS_FILIO 1
159
#cmakedefine HAVE_SIGEV_THREAD_ID 1
160
#cmakedefine HAVE_SIGEV_PORT 1
161
#cmakedefine HAVE_LOG2 1
159
#cmakedefine HAVE_LOG2 1
162
160
163
#cmakedefine HAVE_ISINF 1
161
#cmakedefine HAVE_ISINF 1
(-)mysql-connector-c-6.1.11-src/configure.cmake (-5 / +1 lines)
Lines 533-540 CHECK_SYMBOL_EXISTS(lrand48 "stdlib.h" H Link Here
533
CHECK_SYMBOL_EXISTS(TIOCGWINSZ "sys/ioctl.h" GWINSZ_IN_SYS_IOCTL)
533
CHECK_SYMBOL_EXISTS(TIOCGWINSZ "sys/ioctl.h" GWINSZ_IN_SYS_IOCTL)
534
CHECK_SYMBOL_EXISTS(FIONREAD "sys/ioctl.h" FIONREAD_IN_SYS_IOCTL)
534
CHECK_SYMBOL_EXISTS(FIONREAD "sys/ioctl.h" FIONREAD_IN_SYS_IOCTL)
535
CHECK_SYMBOL_EXISTS(FIONREAD "sys/filio.h" FIONREAD_IN_SYS_FILIO)
535
CHECK_SYMBOL_EXISTS(FIONREAD "sys/filio.h" FIONREAD_IN_SYS_FILIO)
536
CHECK_SYMBOL_EXISTS(SIGEV_THREAD_ID "signal.h;time.h" HAVE_SIGEV_THREAD_ID)
537
CHECK_SYMBOL_EXISTS(SIGEV_PORT "signal.h;time.h;sys/siginfo.h" HAVE_SIGEV_PORT)
538
536
539
CHECK_SYMBOL_EXISTS(log2  math.h HAVE_LOG2)
537
CHECK_SYMBOL_EXISTS(log2  math.h HAVE_LOG2)
540
538
Lines 564-572 CHECK_SYMBOL_EXISTS(EVFILT_TIMER "sys/ty Link Here
564
IF(HAVE_KQUEUE AND HAVE_EVFILT_TIMER)
562
IF(HAVE_KQUEUE AND HAVE_EVFILT_TIMER)
565
  SET(HAVE_KQUEUE_TIMERS 1 CACHE INTERNAL "Have kqueue timer-related filter")
563
  SET(HAVE_KQUEUE_TIMERS 1 CACHE INTERNAL "Have kqueue timer-related filter")
566
ELSEIF(HAVE_TIMER_CREATE AND HAVE_TIMER_SETTIME)
564
ELSEIF(HAVE_TIMER_CREATE AND HAVE_TIMER_SETTIME)
567
  IF(HAVE_SIGEV_THREAD_ID OR HAVE_SIGEV_PORT)
565
  SET(HAVE_POSIX_TIMERS 1 CACHE INTERNAL "Have POSIX timer-related functions")
568
    SET(HAVE_POSIX_TIMERS 1 CACHE INTERNAL "Have POSIX timer-related functions")
569
  ENDIF()
570
ENDIF()
566
ENDIF()
571
567
572
IF(NOT HAVE_POSIX_TIMERS AND NOT HAVE_KQUEUE_TIMERS AND NOT WIN32)
568
IF(NOT HAVE_POSIX_TIMERS AND NOT HAVE_KQUEUE_TIMERS AND NOT WIN32)
(-)mysql-connector-c-6.1.11-src/include/my_timer.h (-6 / +2 lines)
Lines 46-62 struct st_my_timer Link Here
46
  void (*notify_function)(my_timer_t *);
46
  void (*notify_function)(my_timer_t *);
47
};
47
};
48
48
49
C_MODE_START
50
51
#ifdef HAVE_PSI_INTERFACE
49
#ifdef HAVE_PSI_INTERFACE
52
extern PSI_thread_key key_thread_timer_notifier;
50
extern PSI_thread_key key_thread_timer_notifier;
53
#endif
51
#endif
54
52
55
/* Initialize internal components. */
53
/* Initialize internal components. */
56
int my_timer_initialize(void);
54
int my_timer_initialize();
57
55
58
/* Release any resources acquired. */
56
/* Release any resources acquired. */
59
void my_timer_deinitialize(void);
57
void my_timer_deinitialize();
60
58
61
/* Create a timer object. */
59
/* Create a timer object. */
62
int my_timer_create(my_timer_t *timer);
60
int my_timer_create(my_timer_t *timer);
Lines 70-75 int my_timer_cancel(my_timer_t *timer, i Link Here
70
/* Delete a timer object. */
68
/* Delete a timer object. */
71
void my_timer_delete(my_timer_t *timer);
69
void my_timer_delete(my_timer_t *timer);
72
70
73
C_MODE_END
74
75
#endif /* MY_TIMER_H */
71
#endif /* MY_TIMER_H */
(-)mysql-connector-c-6.1.11-src/libmysql/libmysql.c (-1 / +1 lines)
Lines 35-41 Link Here
35
#include <sys/select.h>
35
#include <sys/select.h>
36
#endif
36
#endif
37
#ifdef HAVE_POLL
37
#ifdef HAVE_POLL
38
#include <sys/poll.h>
38
#include <poll.h>
39
#endif
39
#endif
40
#ifdef HAVE_SYS_UN_H
40
#ifdef HAVE_SYS_UN_H
41
#include <sys/un.h>
41
#include <sys/un.h>
(-)mysql-connector-c-6.1.11-src/mysys/posix_timers.c (-267 / +18 lines)
Lines 15-181 Link Here
15
15
16
16
17
#include "my_global.h"
17
#include "my_global.h"
18
#include "my_thread.h"      /* my_thread_init, my_thread_end */
19
#include "my_sys.h"         /* my_message_local */
20
#include "my_timer.h"       /* my_timer_t */
18
#include "my_timer.h"       /* my_timer_t */
21
19
22
#include <string.h>         /* memset */
23
#include <signal.h>
20
#include <signal.h>
21
#include <string.h>         /* memset */
24
22
25
#if defined(HAVE_SIGEV_THREAD_ID)
23
typedef union mysigval {
26
#include <sys/syscall.h>    /* SYS_gettid */
24
        int sival_int;
27
25
        void *sival_ptr;
28
#ifndef sigev_notify_thread_id
26
} mysigval;
29
#define sigev_notify_thread_id   _sigev_un._tid
30
#endif
31
32
#define MY_TIMER_EVENT_SIGNO  (SIGRTMIN)
33
#define MY_TIMER_KILL_SIGNO   (SIGRTMIN+1)
34
35
/* Timer thread ID (TID). */
36
static pid_t timer_notify_thread_id;
37
38
#elif defined(HAVE_SIGEV_PORT)
39
#include <port.h>
40
41
int port_id= -1;
42
43
#endif
44
45
/* Timer thread object. */
46
static my_thread_handle timer_notify_thread;
47
27
48
#if defined(HAVE_SIGEV_THREAD_ID)
49
/**
28
/**
50
  Timer expiration notification thread.
29
  Timer expiration notification thread.
51
30
52
  @param  arg   Barrier object.
31
  @param  arg   Event info.
53
*/
32
*/
54
33
55
static void *
34
static void
56
timer_notify_thread_func(void *arg)
35
timer_notify_thread_func(mysigval arg) {
57
{
36
  my_timer_t *timer = (my_timer_t *)(arg.sival_ptr);
58
  sigset_t set;
37
  timer->notify_function(timer);
59
  siginfo_t info;
60
  my_timer_t *timer;
61
  pthread_barrier_t *barrier= arg;
62
63
  my_thread_init();
64
65
  sigemptyset(&set);
66
  sigaddset(&set, MY_TIMER_EVENT_SIGNO);
67
  sigaddset(&set, MY_TIMER_KILL_SIGNO);
68
69
  /* Get the thread ID of the current thread. */
70
  timer_notify_thread_id= (pid_t) syscall(SYS_gettid);
71
72
  /* Wake up parent thread, timer_notify_thread_id is available. */
73
  pthread_barrier_wait(barrier);
74
75
  while (1)
76
  {
77
    if (sigwaitinfo(&set, &info) < 0)
78
      continue;
79
80
    if (info.si_signo == MY_TIMER_EVENT_SIGNO)
81
    {
82
      timer= (my_timer_t*)info.si_value.sival_ptr;
83
      timer->notify_function(timer);
84
    }
85
    else if (info.si_signo == MY_TIMER_KILL_SIGNO)
86
      break;
87
  }
88
89
  my_thread_end();
90
91
  return NULL;
92
}
38
}
93
39
94
95
/**
96
  Create a helper thread to dispatch timer expiration notifications.
97
98
  @return On success, 0. On error, -1 is returned.
99
*/
100
101
static int
102
start_helper_thread(void)
103
{
104
  pthread_barrier_t barrier;
105
106
  if (pthread_barrier_init(&barrier, NULL, 2))
107
  {
108
    my_message_local(ERROR_LEVEL,
109
                     "Failed to initialize pthread barrier. errno=%d", errno);
110
    return -1;
111
  }
112
113
  if (mysql_thread_create(key_thread_timer_notifier, &timer_notify_thread,
114
                          NULL, timer_notify_thread_func, &barrier))
115
  {
116
    my_message_local(ERROR_LEVEL,
117
                     "Failed to create timer notify thread (errno= %d).",
118
                     errno);
119
    pthread_barrier_destroy(&barrier);
120
    return -1;
121
  }
122
123
  pthread_barrier_wait(&barrier);
124
  pthread_barrier_destroy(&barrier);
125
126
  return 0;
127
}
128
129
130
/**
131
  Initialize internal components.
132
133
  @return On success, 0.
134
          On error, -1 is returned, and errno is set to indicate the error.
135
*/
136
137
int
40
int
138
my_timer_initialize(void)
41
my_timer_initialize()
139
{
42
{
140
  int rc;
43
  return 0;
141
  sigset_t set, old_set;
142
143
  if (sigfillset(&set))
144
  {
145
    my_message_local(ERROR_LEVEL,
146
                     "Failed to intialize signal set (errno=%d).", errno);
147
    return -1;
148
  }
149
150
  /*
151
    Temporarily block all signals. New thread will inherit signal
152
    mask of the current thread.
153
  */
154
  if (pthread_sigmask(SIG_BLOCK, &set, &old_set))
155
    return -1;
156
157
  /* Create a helper thread. */
158
  rc= start_helper_thread();
159
160
  /* Restore the signal mask. */
161
  pthread_sigmask(SIG_SETMASK, &old_set, NULL);
162
163
  return rc;
164
}
44
}
165
45
166
46
167
/**
168
  Release any resources that were allocated as part of initialization.
169
*/
170
171
void
47
void
172
my_timer_deinitialize(void)
48
my_timer_deinitialize(void)
173
{
49
{
174
  /* Kill helper thread. */
175
  pthread_kill(timer_notify_thread.thread, MY_TIMER_KILL_SIGNO);
176
177
  /* Wait for helper thread termination. */
178
  my_thread_join(&timer_notify_thread, NULL);
179
}
50
}
180
51
181
52
Lines 195-330 my_timer_create(my_timer_t *timer) Link Here
195
66
196
  memset(&sigev, 0, sizeof(sigev));
67
  memset(&sigev, 0, sizeof(sigev));
197
68
69
  sigev.sigev_notify= SIGEV_THREAD;
198
  sigev.sigev_value.sival_ptr= timer;
70
  sigev.sigev_value.sival_ptr= timer;
199
  sigev.sigev_signo= MY_TIMER_EVENT_SIGNO;
71
  sigev.sigev_notify_function= &timer_notify_thread_func;
200
  sigev.sigev_notify= SIGEV_SIGNAL | SIGEV_THREAD_ID;
201
  sigev.sigev_notify_thread_id= timer_notify_thread_id;
202
203
  return timer_create(CLOCK_MONOTONIC, &sigev, &timer->id);
204
}
205
#elif defined(HAVE_SIGEV_PORT)
206
/**
207
  Timer expiration notification thread.
208
209
  @param  arg   Barrier object.
210
*/
211
212
static void *
213
timer_notify_thread_func(void *arg MY_ATTRIBUTE((unused)))
214
{
215
  port_event_t port_event;
216
  my_timer_t *timer;
217
218
  my_thread_init();
219
220
  while (1)
221
  {
222
    if (port_get(port_id, &port_event, NULL))
223
      break;
224
225
    if (port_event.portev_source != PORT_SOURCE_TIMER)
226
      continue;
227
228
    timer= (my_timer_t*)port_event.portev_user;
229
    timer->notify_function(timer);
230
  }
231
232
  my_thread_end();
233
234
  return NULL;
235
}
236
237
238
/**
239
  Create a helper thread to dispatch timer expiration notifications.
240
241
  @return On success, 0. On error, -1 is returned.
242
*/
243
244
static int
245
start_helper_thread(void)
246
{
247
  if (mysql_thread_create(key_thread_timer_notifier, &timer_notify_thread,
248
                          NULL, timer_notify_thread_func, NULL))
249
  {
250
    my_message_local(ERROR_LEVEL,
251
                     "Failed to create timer notify thread (errno= %d).",
252
                     errno);
253
    return -1;
254
  }
255
256
  return 0;
257
}
258
259
260
/**
261
  Initialize internal components.
262
263
  @return On success, 0.
264
          On error, -1 is returned, and errno is set to indicate the error.
265
*/
266
267
int
268
my_timer_initialize(void)
269
{
270
  int rc;
271
272
  if ((port_id= port_create()) < 0)
273
  {
274
    my_message_local(ERROR_LEVEL, "Failed to create port (errno= %d).", errno);
275
    return -1;
276
  }
277
278
  /* Create a helper thread. */
279
  rc= start_helper_thread();
280
281
  return rc;
282
}
283
284
285
/**
286
  Release any resources that were allocated as part of initialization.
287
*/
288
289
void
290
my_timer_deinitialize(void)
291
{
292
  DBUG_ASSERT(port_id >= 0);
293
294
  // close port
295
  close(port_id);
296
297
  /* Wait for helper thread termination. */
298
  my_thread_join(&timer_notify_thread, NULL);
299
}
300
301
302
/**
303
  Create a timer object.
304
305
  @param  timer   Location where the timer ID is returned.
306
307
  @return On success, 0.
308
          On error, -1 is returned, and errno is set to indicate the error.
309
*/
310
311
int
312
my_timer_create(my_timer_t *timer)
313
{
314
  struct sigevent sigev;
315
  port_notify_t port_notify;
316
317
  port_notify.portnfy_port= port_id;
318
  port_notify.portnfy_user= timer;
319
320
  memset(&sigev, 0, sizeof(sigev));
321
  sigev.sigev_value.sival_ptr= &port_notify;
322
  sigev.sigev_notify= SIGEV_PORT;
323
72
73
#ifdef __sun // CLOCK_MONOTONIC not supported on Solaris even if it compiles.
324
  return timer_create(CLOCK_REALTIME, &sigev, &timer->id);
74
  return timer_create(CLOCK_REALTIME, &sigev, &timer->id);
325
}
75
#else
76
  return timer_create(CLOCK_MONOTONIC, &sigev, &timer->id);
326
#endif
77
#endif
327
78
}
328
79
329
/**
80
/**
330
  Set the time until the next expiration of the timer.
81
  Set the time until the next expiration of the timer.

Return to bug 663236