| line |
true |
false |
branch |
|
342
|
0 |
0 |
if (self->wbuf_off > 0) { |
|
349
|
0 |
0 |
if (self->wbuf_cap >= total) return; |
|
350
|
0 |
0 |
size_t new_cap = self->wbuf_cap ? self->wbuf_cap : BUF_INIT_SIZE; |
|
351
|
0 |
0 |
while (new_cap < total) new_cap *= 2; |
|
358
|
0 |
0 |
if (self->rbuf_cap >= total) return; |
|
359
|
0 |
0 |
size_t new_cap = self->rbuf_cap ? self->rbuf_cap : BUF_INIT_SIZE; |
|
360
|
0 |
0 |
while (new_cap < total) new_cap *= 2; |
|
376
|
0 |
0 |
if (!self->reading && self->fd >= 0) { |
|
|
0 |
0 |
if (!self->reading && self->fd >= 0) { |
|
383
|
0 |
0 |
if (self->reading) { |
|
390
|
0 |
0 |
if (!self->writing && self->fd >= 0) { |
|
|
0 |
0 |
if (!self->writing && self->fd >= 0) { |
|
397
|
0 |
0 |
if (self->writing) { |
|
404
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED && self->callback_depth == 0) { |
|
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED && self->callback_depth == 0) { |
|
419
|
0 |
0 |
if (!cb) return; |
|
426
|
0 |
0 |
PUSHMARK(SP); |
|
427
|
0 |
0 |
EXTEND(SP, 2); |
|
428
|
0 |
0 |
if (result) |
|
432
|
0 |
0 |
if (error) |
|
438
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
439
|
0 |
0 |
warn("EV::Memcached: callback error: %s", SvPV_nolen(ERRSV)); |
|
440
|
0 |
0 |
sv_setsv(ERRSV, &PL_sv_undef); |
|
442
|
0 |
0 |
FREETMPS; |
|
451
|
0 |
0 |
if (NULL == cb) { if (arg) SvREFCNT_dec(arg); return; } |
|
|
0 |
0 |
if (NULL == cb) { if (arg) SvREFCNT_dec(arg); return; } |
|
458
|
0 |
0 |
PUSHMARK(SP); |
|
459
|
0 |
0 |
if (arg) XPUSHs(sv_2mortal(arg)); |
|
|
0 |
0 |
if (arg) XPUSHs(sv_2mortal(arg)); |
|
462
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
463
|
0 |
0 |
warn("EV::Memcached: %s callback error: %s", label, SvPV_nolen(ERRSV)); |
|
464
|
0 |
0 |
sv_setsv(ERRSV, &PL_sv_undef); |
|
466
|
0 |
0 |
FREETMPS; |
|
485
|
0 |
0 |
if (self->keepalive <= 0 || self->path) return; |
|
|
0 |
0 |
if (self->keepalive <= 0 || self->path) return; |
|
501
|
0 |
0 |
if (check_destroyed(self)) return; |
|
502
|
0 |
0 |
if (!self->intentional_disconnect && self->reconnect) |
|
|
0 |
0 |
if (!self->intentional_disconnect && self->reconnect) |
|
519
|
0 |
0 |
if (check_destroyed(self)) return; |
|
523
|
0 |
0 |
if (!self->username || !self->password) |
|
|
0 |
0 |
if (!self->username || !self->password) |
|
538
|
0 |
0 |
CLEAR_HANDLER(cbt->cb); |
|
539
|
0 |
0 |
if (cbt->stats_hv) { |
|
543
|
0 |
0 |
if ((cbt->cmd == CB_CMD_MGET_FENCE || cbt->cmd == CB_CMD_MGETS_FENCE) && cbt->mget_results) { |
|
|
0 |
0 |
if ((cbt->cmd == CB_CMD_MGET_FENCE || cbt->cmd == CB_CMD_MGETS_FENCE) && cbt->mget_results) { |
|
|
0 |
0 |
if ((cbt->cmd == CB_CMD_MGET_FENCE || cbt->cmd == CB_CMD_MGETS_FENCE) && cbt->mget_results) { |
|
552
|
0 |
0 |
CLEAR_HANDLER(wt->cb); |
|
553
|
0 |
0 |
if (wt->packet) { Safefree(wt->packet); wt->packet = NULL; } |
|
554
|
0 |
0 |
if (wt->stats_hv) { |
|
558
|
0 |
0 |
if ((wt->cmd == CB_CMD_MGET_FENCE || wt->cmd == CB_CMD_MGETS_FENCE) && wt->mget_results) { |
|
|
0 |
0 |
if ((wt->cmd == CB_CMD_MGET_FENCE || wt->cmd == CB_CMD_MGETS_FENCE) && wt->mget_results) { |
|
|
0 |
0 |
if ((wt->cmd == CB_CMD_MGET_FENCE || wt->cmd == CB_CMD_MGETS_FENCE) && wt->mget_results) { |
|
577
|
0 |
0 |
if (self->in_cb_cleanup) return; |
|
580
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
584
|
0 |
0 |
if (cbt->counted) self->pending_count--; |
|
587
|
0 |
0 |
if (mark_skipped) cbt->skipped = 1; |
|
588
|
0 |
0 |
if (cbt->cb && !already_skipped) { |
|
|
0 |
0 |
if (cbt->cb && !already_skipped) { |
|
590
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) { |
|
607
|
0 |
0 |
if (self->in_wait_cleanup) return; |
|
610
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue)) { |
|
616
|
0 |
0 |
if (wt->cb) { |
|
618
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) { |
|
646
|
0 |
0 |
if (self->fd >= 0) { |
|
665
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
667
|
0 |
0 |
if (!self->resume_waiting_on_reconnect) { |
|
669
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
672
|
0 |
0 |
if (was_connected) { |
|
674
|
0 |
0 |
if (check_destroyed(self)) return; |
|
677
|
0 |
0 |
if (reason) { |
|
679
|
0 |
0 |
if (check_destroyed(self)) return; |
|
682
|
0 |
0 |
if (!self->intentional_disconnect && self->reconnect) { |
|
|
0 |
0 |
if (!self->intentional_disconnect && self->reconnect) { |
|
692
|
0 |
0 |
if (self->reconnect_timer_active) return; |
|
693
|
0 |
0 |
if (self->max_reconnect_attempts > 0 && |
|
694
|
0 |
0 |
self->reconnect_attempts >= self->max_reconnect_attempts) { |
|
706
|
0 |
0 |
if (delay < 0) delay = 0; |
|
714
|
0 |
0 |
if (self->command_timeout_ms <= 0) return; |
|
715
|
0 |
0 |
if (!self->connected) return; |
|
717
|
0 |
0 |
if (self->cmd_timer_active) { |
|
731
|
0 |
0 |
if (self->cmd_timer_active) { |
|
738
|
0 |
0 |
if (self->connect_timer_active) { |
|
745
|
0 |
0 |
if (self->reconnect_timer_active) { |
|
752
|
0 |
0 |
if (self->waiting_timer_active) { |
|
762
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) return; |
|
764
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) { |
|
780
|
0 |
0 |
if (!self->username || !self->password) return; |
|
|
0 |
0 |
if (!self->username || !self->password) return; |
|
801
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) return; |
|
814
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) return; |
|
833
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue)) { |
|
837
|
0 |
0 |
if (wt->queued_at + timeout > now) break; /* not expired yet */ |
|
842
|
0 |
0 |
if (wt->cb) { |
|
844
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) { |
|
857
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) return; |
|
863
|
0 |
0 |
if (check_destroyed(self)) return; |
|
865
|
0 |
0 |
if (!ngx_queue_empty(&self->wait_queue) && self->waiting_timeout_ms > 0) |
|
|
0 |
0 |
if (!ngx_queue_empty(&self->wait_queue) && self->waiting_timeout_ms > 0) |
|
870
|
0 |
0 |
if (self->waiting_timer_active) return; |
|
871
|
0 |
0 |
if (self->waiting_timeout_ms <= 0) return; |
|
872
|
0 |
0 |
if (ngx_queue_empty(&self->wait_queue)) return; |
|
878
|
0 |
0 |
if (delay < 0.0) delay = 0.0; |
|
891
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue) && self->connected) { |
|
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue) && self->connected) { |
|
898
|
0 |
0 |
if (self->max_pending > 0 && self->pending_count >= self->max_pending |
|
|
0 |
0 |
if (self->max_pending > 0 && self->pending_count >= self->max_pending |
|
899
|
0 |
0 |
&& !wt->no_response && wt->counted) |
|
|
0 |
0 |
&& !wt->no_response && wt->counted) |
|
908
|
0 |
0 |
if (!wt->no_response) { |
|
918
|
0 |
0 |
if (cbt->counted) self->pending_count++; |
|
938
|
0 |
0 |
if (self->next_opaque == 0) self->next_opaque = 1; |
|
954
|
0 |
0 |
if (extras_len > 0) { memcpy(p, extras, extras_len); p += extras_len; } |
|
955
|
0 |
0 |
if (key_len > 0) { memcpy(p, key, key_len); p += key_len; } |
|
956
|
0 |
0 |
if (value_len > 0) { memcpy(p, value, value_len); } |
|
968
|
0 |
0 |
if (key_len > MC_MAX_KEY_LEN) |
|
974
|
0 |
0 |
if (self->connected) { |
|
994
|
0 |
0 |
if (self->waiting_timeout_ms > 0) |
|
1007
|
0 |
0 |
if (key_len > MC_MAX_KEY_LEN) |
|
1014
|
0 |
0 |
int counted = (cmd != CB_CMD_MGET_ENTRY && cmd != CB_CMD_MGETS_ENTRY); |
|
|
0 |
0 |
int counted = (cmd != CB_CMD_MGET_ENTRY && cmd != CB_CMD_MGETS_ENTRY); |
|
1017
|
0 |
0 |
int can_send = self->connected && |
|
1018
|
0 |
0 |
(self->max_pending <= 0 || self->pending_count < self->max_pending || !counted); |
|
|
0 |
0 |
(self->max_pending <= 0 || self->pending_count < self->max_pending || !counted); |
|
|
0 |
0 |
(self->max_pending <= 0 || self->pending_count < self->max_pending || !counted); |
|
1020
|
0 |
0 |
if (can_send) { |
|
1028
|
0 |
0 |
if (cb) { cbt->cb = newSVsv(cb); } |
|
1033
|
0 |
0 |
if (cmd == CB_CMD_STATS) { |
|
1037
|
0 |
0 |
if (counted) self->pending_count++; |
|
1051
|
0 |
0 |
if (cb) { wt->cb = newSVsv(cb); } |
|
1057
|
0 |
0 |
if (cmd == CB_CMD_STATS) { |
|
1064
|
0 |
0 |
if (self->waiting_timeout_ms > 0) |
|
1078
|
0 |
0 |
if (count <= 0) { |
|
1079
|
0 |
0 |
if (cb) { |
|
1089
|
0 |
0 |
int entry_cmd = full_info ? CB_CMD_MGETS_ENTRY : CB_CMD_MGET_ENTRY; |
|
1090
|
0 |
0 |
int fence_cmd = full_info ? CB_CMD_MGETS_FENCE : CB_CMD_MGET_FENCE; |
|
1097
|
0 |
0 |
for (i = 0; i < count; i++) { |
|
1099
|
0 |
0 |
if (!sv || !SvOK(*sv)) continue; |
|
|
0 |
0 |
if (!sv || !SvOK(*sv)) continue; |
|
1102
|
0 |
0 |
if (key_len > MC_MAX_KEY_LEN) |
|
1108
|
0 |
0 |
for (i = 0; i < count; i++) { |
|
1110
|
0 |
0 |
if (!sv || !SvOK(*sv)) continue; |
|
|
0 |
0 |
if (!sv || !SvOK(*sv)) continue; |
|
1121
|
0 |
0 |
if (can_send) { |
|
1159
|
0 |
0 |
if (can_send) { |
|
1166
|
0 |
0 |
if (cb) { cbt->cb = newSVsv(cb); } |
|
1184
|
0 |
0 |
if (cb) { wt->cb = newSVsv(cb); } |
|
1201
|
0 |
0 |
if (self->waiting_timeout_ms > 0) |
|
1214
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
1219
|
0 |
0 |
if ((int32_t)(cbt->opaque - opaque) >= 0) break; |
|
1220
|
0 |
0 |
if (!cbt->quiet) break; /* non-quiet should always get response */ |
|
1223
|
0 |
0 |
if (cbt->counted) self->pending_count--; |
|
1226
|
0 |
0 |
if (cbt->cb && !cbt->skipped && |
|
|
0 |
0 |
if (cbt->cb && !cbt->skipped && |
|
1227
|
0 |
0 |
cbt->cmd != CB_CMD_MGET_ENTRY && cbt->cmd != CB_CMD_MGETS_ENTRY) { |
|
|
0 |
0 |
cbt->cmd != CB_CMD_MGET_ENTRY && cbt->cmd != CB_CMD_MGETS_ENTRY) { |
|
1229
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) { |
|
1249
|
0 |
0 |
if ((uint32_t)extras_len + key_len > body_len) { |
|
1261
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
1264
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) { |
|
1272
|
0 |
0 |
if (cbt->opaque != opaque) { |
|
1274
|
0 |
0 |
if (opaque == 0) return; |
|
1283
|
0 |
0 |
if (cbt->cmd == CB_CMD_STATS && status == MC_STATUS_OK && key_len > 0) { |
|
|
0 |
0 |
if (cbt->cmd == CB_CMD_STATS && status == MC_STATUS_OK && key_len > 0) { |
|
|
0 |
0 |
if (cbt->cmd == CB_CMD_STATS && status == MC_STATUS_OK && key_len > 0) { |
|
1284
|
0 |
0 |
if (cbt->stats_hv) { |
|
1293
|
0 |
0 |
if (cbt->counted) self->pending_count--; |
|
1296
|
0 |
0 |
if (status != MC_STATUS_OK) { |
|
1298
|
0 |
0 |
if (status == MC_STATUS_KEY_NOT_FOUND && |
|
1299
|
0 |
0 |
(cbt->cmd == CB_CMD_GET || cbt->cmd == CB_CMD_GETS || |
|
|
0 |
0 |
(cbt->cmd == CB_CMD_GET || cbt->cmd == CB_CMD_GETS || |
|
1300
|
0 |
0 |
cbt->cmd == CB_CMD_GAT || cbt->cmd == CB_CMD_GATS)) { |
|
|
0 |
0 |
cbt->cmd == CB_CMD_GAT || cbt->cmd == CB_CMD_GATS)) { |
|
1301
|
0 |
0 |
if (cbt->cb && !cbt->skipped) |
|
|
0 |
0 |
if (cbt->cb && !cbt->skipped) |
|
1304
|
0 |
0 |
else if (cbt->cmd == CB_CMD_MGET_ENTRY || cbt->cmd == CB_CMD_MGETS_ENTRY) { |
|
|
0 |
0 |
else if (cbt->cmd == CB_CMD_MGET_ENTRY || cbt->cmd == CB_CMD_MGETS_ENTRY) { |
|
1308
|
0 |
0 |
else if (cbt->cmd == CB_CMD_SASL_AUTH) { |
|
1309
|
0 |
0 |
if (cbt->cb && !cbt->skipped) { |
|
|
0 |
0 |
if (cbt->cb && !cbt->skipped) { |
|
1311
|
0 |
0 |
if (value_len > 0) |
|
1316
|
0 |
0 |
} else if (!cbt->cb) { |
|
1319
|
0 |
0 |
if (value_len > 0) |
|
1332
|
0 |
0 |
if (cbt->cb && !cbt->skipped) { |
|
|
0 |
0 |
if (cbt->cb && !cbt->skipped) { |
|
1335
|
0 |
0 |
if (value_len > 0) |
|
1342
|
0 |
0 |
if (self->magic != MC_MAGIC_FREED) { |
|
1352
|
0 |
0 |
if (cbt->skipped) { |
|
1361
|
0 |
0 |
if (cbt->cb) |
|
1367
|
0 |
0 |
if (cbt->cb) { |
|
1370
|
0 |
0 |
if (extras_len >= 4) |
|
1383
|
0 |
0 |
if (cbt->cb) |
|
1388
|
0 |
0 |
if (cbt->cb) { |
|
1389
|
0 |
0 |
if (value_len >= 8) { |
|
1401
|
0 |
0 |
if (cbt->cb) |
|
1406
|
0 |
0 |
if (cbt->cb) |
|
1414
|
0 |
0 |
if (cbt->cb && cbt->stats_hv) { |
|
|
0 |
0 |
if (cbt->cb && cbt->stats_hv) { |
|
1422
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
1429
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
1432
|
0 |
0 |
if (extras_len >= 4) |
|
1442
|
0 |
0 |
if (cbt->cb && cbt->mget_results) { |
|
|
0 |
0 |
if (cbt->cb && cbt->mget_results) { |
|
1450
|
0 |
0 |
if (self->magic != MC_MAGIC_FREED) { |
|
1460
|
0 |
0 |
while (self->rbuf_len >= MC_HEADER_SIZE) { |
|
1462
|
0 |
0 |
if ((uint8_t)self->rbuf[0] != MC_RES_MAGIC) { |
|
1472
|
0 |
0 |
if (body_len > 0x10000000u) { |
|
1478
|
0 |
0 |
if (self->rbuf_len < total_len) break; /* incomplete packet */ |
|
1481
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
1482
|
0 |
0 |
if (!self->connected) return; /* disconnect() called from callback */ |
|
1486
|
0 |
0 |
if (self->rbuf_len > 0) |
|
1492
|
0 |
0 |
if (processed > 0 && self->cmd_timer_active) { |
|
|
0 |
0 |
if (processed > 0 && self->cmd_timer_active) { |
|
1493
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) |
|
1508
|
0 |
0 |
if (n > 0) { |
|
1511
|
0 |
0 |
} else if (n == 0) { |
|
1514
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
1523
|
0 |
0 |
while (self->wbuf_off < self->wbuf_len) { |
|
1526
|
0 |
0 |
if (n > 0) { |
|
1528
|
0 |
0 |
} else if (n < 0) { |
|
1529
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) |
|
1544
|
0 |
0 |
if (getsockopt(self->fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0 || err != 0) { |
|
|
0 |
0 |
if (getsockopt(self->fd, SOL_SOCKET, SO_ERROR, &err, &len) < 0 || err != 0) { |
|
1547
|
0 |
0 |
strerror(err ? err : errno)); |
|
1571
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) return; |
|
1575
|
0 |
0 |
if (self->connecting) { |
|
1576
|
0 |
0 |
if (revents & EV_WRITE) { |
|
1584
|
0 |
0 |
if (revents & EV_READ) { |
|
1586
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) { |
|
1593
|
0 |
0 |
if (revents & EV_WRITE) { |
|
1595
|
0 |
0 |
if (rv < 0) { |
|
1613
|
0 |
0 |
if (self->path) { |
|
1618
|
0 |
0 |
if (strlen(self->path) >= sizeof(addr.sun_path)) { |
|
1625
|
0 |
0 |
if (fd < 0) { |
|
1635
|
0 |
0 |
if (fl < 0 || fcntl(fd, F_SETFL, fl | O_NONBLOCK) < 0) { |
|
|
0 |
0 |
if (fl < 0 || fcntl(fd, F_SETFL, fl | O_NONBLOCK) < 0) { |
|
1655
|
0 |
0 |
if (ret != 0) { |
|
1663
|
0 |
0 |
if (fd < 0) { |
|
1674
|
0 |
0 |
if (fl < 0 || fcntl(fd, F_SETFL, fl | O_NONBLOCK) < 0) { |
|
|
0 |
0 |
if (fl < 0 || fcntl(fd, F_SETFL, fl | O_NONBLOCK) < 0) { |
|
1693
|
0 |
0 |
if (ret == 0) { |
|
1707
|
0 |
0 |
if (errno != EINPROGRESS) { |
|
1726
|
0 |
0 |
if (self->connect_timeout_ms > 0) { |
|
1743
|
0 |
8 |
I_EV_API("EV::Memcached"); |
|
|
8 |
0 |
I_EV_API("EV::Memcached"); |
|
|
0 |
8 |
I_EV_API("EV::Memcached"); |
|
1757
|
0 |
0 |
if ((items - 1) % 2 != 0) croak("odd number of arguments"); |
|
1784
|
0 |
0 |
for (i = 1; i < items; i += 2) { |
|
1788
|
0 |
0 |
if (strEQ(k, "host")) host_sv = v; |
|
1789
|
0 |
0 |
else if (strEQ(k, "port")) port = SvIV(v); |
|
1790
|
0 |
0 |
else if (strEQ(k, "path")) path_sv = v; |
|
1791
|
0 |
0 |
else if (strEQ(k, "on_error")) { |
|
1792
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_error); |
|
1793
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_error = newSVsv(v); |
|
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_error = newSVsv(v); |
|
1795
|
0 |
0 |
else if (strEQ(k, "on_connect")) { |
|
1796
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_connect = newSVsv(v); |
|
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_connect = newSVsv(v); |
|
1798
|
0 |
0 |
else if (strEQ(k, "on_disconnect")) { |
|
1799
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_disconnect = newSVsv(v); |
|
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_disconnect = newSVsv(v); |
|
1801
|
0 |
0 |
else if (strEQ(k, "max_pending")) RETVAL->max_pending = SvIV(v); |
|
1802
|
0 |
0 |
else if (strEQ(k, "waiting_timeout")) RETVAL->waiting_timeout_ms = SvIV(v); |
|
1803
|
0 |
0 |
else if (strEQ(k, "connect_timeout")) RETVAL->connect_timeout_ms = SvIV(v); |
|
1804
|
0 |
0 |
else if (strEQ(k, "command_timeout")) RETVAL->command_timeout_ms = SvIV(v); |
|
1805
|
0 |
0 |
else if (strEQ(k, "resume_waiting_on_reconnect")) RETVAL->resume_waiting_on_reconnect = SvTRUE(v) ? 1 : 0; |
|
1806
|
0 |
0 |
else if (strEQ(k, "priority")) RETVAL->priority = SvIV(v); |
|
1807
|
0 |
0 |
else if (strEQ(k, "keepalive")) RETVAL->keepalive = SvIV(v); |
|
1808
|
0 |
0 |
else if (strEQ(k, "reconnect")) do_reconnect = SvTRUE(v) ? 1 : 0; |
|
1809
|
0 |
0 |
else if (strEQ(k, "reconnect_delay")) reconnect_delay = SvIV(v); |
|
1810
|
0 |
0 |
else if (strEQ(k, "max_reconnect_attempts")) max_reconnect_attempts = SvIV(v); |
|
1811
|
0 |
0 |
else if (strEQ(k, "username")) { |
|
1812
|
0 |
0 |
if (SvOK(v)) RETVAL->username = savepv(SvPV_nolen(v)); |
|
1814
|
0 |
0 |
else if (strEQ(k, "password")) { |
|
1815
|
0 |
0 |
if (SvOK(v)) RETVAL->password = savepv(SvPV_nolen(v)); |
|
1817
|
0 |
0 |
else if (strEQ(k, "loop")) { |
|
1822
|
0 |
0 |
if (host_sv && path_sv) { |
|
|
0 |
0 |
if (host_sv && path_sv) { |
|
1825
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_error); |
|
1826
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_connect); |
|
1827
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_disconnect); |
|
1828
|
0 |
0 |
if (RETVAL->username) Safefree(RETVAL->username); |
|
1829
|
0 |
0 |
if (RETVAL->password) Safefree(RETVAL->password); |
|
1835
|
0 |
0 |
if (do_reconnect) { |
|
1841
|
0 |
0 |
if (host_sv && SvOK(host_sv)) { |
|
|
0 |
0 |
if (host_sv && SvOK(host_sv)) { |
|
1845
|
0 |
0 |
else if (path_sv && SvOK(path_sv)) { |
|
|
0 |
0 |
else if (path_sv && SvOK(path_sv)) { |
|
1857
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
1861
|
0 |
0 |
if (self->callback_depth > 0) { |
|
1871
|
0 |
0 |
if (self->fd >= 0) { close(self->fd); self->fd = -1; } |
|
1874
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
1880
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue)) { |
|
1889
|
0 |
0 |
CLEAR_HANDLER(self->on_error); |
|
1890
|
0 |
0 |
CLEAR_HANDLER(self->on_connect); |
|
1891
|
0 |
0 |
CLEAR_HANDLER(self->on_disconnect); |
|
1915
|
0 |
0 |
if (!PL_dirty) { |
|
1922
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
1928
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue)) { |
|
1938
|
0 |
0 |
CLEAR_HANDLER(self->on_error); |
|
1939
|
0 |
0 |
CLEAR_HANDLER(self->on_connect); |
|
1940
|
0 |
0 |
CLEAR_HANDLER(self->on_disconnect); |
|
1956
|
0 |
0 |
if (self->connected || self->connecting) |
|
|
0 |
0 |
if (self->connected || self->connecting) |
|
1976
|
0 |
0 |
if (self->connected || self->connecting) |
|
|
0 |
0 |
if (self->connected || self->connecting) |
|
2001
|
0 |
0 |
if (self->connected || self->connecting) { |
|
|
0 |
0 |
if (self->connected || self->connecting) { |
|
2013
|
0 |
0 |
RETVAL = self->connected || self->connecting; |
|
|
0 |
0 |
RETVAL = self->connected || self->connecting; |
|
|
0 |
0 |
RETVAL = self->connected || self->connecting; |
|
2021
|
0 |
0 |
if (items > 1) { |
|
2022
|
0 |
0 |
CLEAR_HANDLER(self->on_error); |
|
2023
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
2027
|
0 |
0 |
RETVAL = self->on_error ? newSVsv(self->on_error) : &PL_sv_undef; |
|
2036
|
0 |
0 |
if (items > 1) { |
|
2037
|
0 |
0 |
CLEAR_HANDLER(self->on_connect); |
|
2038
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
2042
|
0 |
0 |
RETVAL = self->on_connect ? newSVsv(self->on_connect) : &PL_sv_undef; |
|
2051
|
0 |
0 |
if (items > 1) { |
|
2052
|
0 |
0 |
CLEAR_HANDLER(self->on_disconnect); |
|
2053
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (SvOK(ST(1)) && SvROK(ST(1)) && SvTYPE(SvRV(ST(1))) == SVt_PVCV) { |
|
2057
|
0 |
0 |
RETVAL = self->on_disconnect ? newSVsv(self->on_disconnect) : &PL_sv_undef; |
|
2070
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2078
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
2082
|
0 |
0 |
UV expiry = extra > 0 ? SvUV(ST(3)) : 0; |
|
2083
|
0 |
0 |
UV flags = extra > 1 ? SvUV(ST(4)) : 0; |
|
2091
|
0 |
0 |
if (!cb && ix == 0) { |
|
|
0 |
0 |
if (!cb && ix == 0) { |
|
2104
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2113
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
2117
|
0 |
0 |
UV expiry = extra > 0 ? SvUV(ST(4)) : 0; |
|
2118
|
0 |
0 |
UV flags = extra > 1 ? SvUV(ST(5)) : 0; |
|
2134
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2138
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2148
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2152
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2164
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2171
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
2175
|
0 |
0 |
UV delta = extra > 0 ? SvUV(ST(2)) : 1; |
|
2176
|
0 |
0 |
UV initial = extra > 1 ? SvUV(ST(3)) : 0; |
|
2177
|
0 |
0 |
UV expiry = extra > 2 ? SvUV(ST(4)) : 0xFFFFFFFF; |
|
2184
|
0 |
0 |
mc_enqueue_cmd(aTHX_ self, ix == 0 ? MC_OP_INCR : MC_OP_DECR, |
|
2194
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2199
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2201
|
0 |
0 |
mc_enqueue_cmd(aTHX_ self, ix == 0 ? MC_OP_APPEND : MC_OP_PREPEND, |
|
2212
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2216
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2232
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2236
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
2240
|
0 |
0 |
UV expiry = extra > 0 ? SvUV(ST(1)) : 0; |
|
2245
|
0 |
0 |
if (expiry > 0) { |
|
2251
|
0 |
0 |
if (cb) |
|
2266
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2268
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2281
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2285
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
|
0 |
0 |
if (extra > 0 && SvROK(ST(items-1)) && SvTYPE(SvRV(ST(items-1))) == SVt_PVCV) { |
|
2292
|
0 |
0 |
if (extra > 0 && SvOK(ST(1))) { |
|
|
0 |
0 |
if (extra > 0 && SvOK(ST(1))) { |
|
2306
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2308
|
0 |
0 |
if (!SvROK(keys_sv) || SvTYPE(SvRV(keys_sv)) != SVt_PVAV) |
|
|
0 |
0 |
if (!SvROK(keys_sv) || SvTYPE(SvRV(keys_sv)) != SVt_PVAV) |
|
2311
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2321
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2326
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2345
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
|
0 |
0 |
MC_CROAK_UNLESS_CONNECTED(self); |
|
2347
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
|
0 |
0 |
SV *cb = (SvOK(cb_sv) && SvROK(cb_sv)) ? cb_sv : NULL; |
|
2356
|
0 |
0 |
RETVAL = self->pending_count; |
|
2363
|
0 |
0 |
RETVAL = self->waiting_count; |
|
2371
|
0 |
0 |
if (items > 1) { |
|
2374
|
0 |
0 |
if (self->max_pending < 0) self->max_pending = 0; |
|
2376
|
0 |
0 |
if (self->connected && self->max_pending > old) |
|
|
0 |
0 |
if (self->connected && self->max_pending > old) |
|
2379
|
0 |
0 |
RETVAL = self->max_pending; |
|
2388
|
0 |
0 |
if (items > 1) { |
|
2390
|
0 |
0 |
if (self->waiting_timeout_ms < 0) self->waiting_timeout_ms = 0; |
|
2392
|
0 |
0 |
RETVAL = self->waiting_timeout_ms; |
|
2401
|
0 |
0 |
if (items > 1) { |
|
2404
|
0 |
0 |
RETVAL = self->resume_waiting_on_reconnect; |
|
2413
|
0 |
0 |
if (items > 1) { |
|
2415
|
0 |
0 |
if (self->connect_timeout_ms < 0) self->connect_timeout_ms = 0; |
|
2417
|
0 |
0 |
RETVAL = self->connect_timeout_ms; |
|
2426
|
0 |
0 |
if (items > 1) { |
|
2428
|
0 |
0 |
if (self->command_timeout_ms < 0) self->command_timeout_ms = 0; |
|
2429
|
0 |
0 |
if (self->command_timeout_ms == 0) |
|
2431
|
0 |
0 |
else if (!ngx_queue_empty(&self->cb_queue)) |
|
2434
|
0 |
0 |
RETVAL = self->command_timeout_ms; |
|
2446
|
0 |
0 |
if (!enable) { |
|
2455
|
0 |
0 |
RETVAL = self->reconnect; |
|
2463
|
0 |
0 |
if (items > 1) { |
|
2465
|
0 |
0 |
if (self->priority < -2) self->priority = -2; |
|
2466
|
0 |
0 |
if (self->priority > 2) self->priority = 2; |
|
2468
|
0 |
0 |
if (self->reading) { |
|
2475
|
0 |
0 |
if (self->writing) { |
|
2483
|
0 |
0 |
RETVAL = self->priority; |
|
2492
|
0 |
0 |
if (items > 1) { |
|
2494
|
0 |
0 |
if (self->keepalive < 0) self->keepalive = 0; |
|
2495
|
0 |
0 |
if (self->connected && self->fd >= 0) |
|
|
0 |
0 |
if (self->connected && self->fd >= 0) |
|
2498
|
0 |
0 |
RETVAL = self->keepalive; |