| 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) { |
|
1396
|
0 |
0 |
if (cbt->cb) |
|
1401
|
0 |
0 |
if (cbt->cb) |
|
1409
|
0 |
0 |
if (cbt->cb && cbt->stats_hv) { |
|
|
0 |
0 |
if (cbt->cb && cbt->stats_hv) { |
|
1417
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
1424
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
|
0 |
0 |
if (cbt->mget_results && key_len > 0) { |
|
1427
|
0 |
0 |
if (extras_len >= 4) |
|
1437
|
0 |
0 |
if (cbt->cb && cbt->mget_results) { |
|
|
0 |
0 |
if (cbt->cb && cbt->mget_results) { |
|
1445
|
0 |
0 |
if (self->magic != MC_MAGIC_FREED) { |
|
1455
|
0 |
0 |
while (self->rbuf_len >= MC_HEADER_SIZE) { |
|
1457
|
0 |
0 |
if ((uint8_t)self->rbuf[0] != MC_RES_MAGIC) { |
|
1467
|
0 |
0 |
if (body_len > 0x10000000u) { |
|
1473
|
0 |
0 |
if (self->rbuf_len < total_len) break; /* incomplete packet */ |
|
1476
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
1477
|
0 |
0 |
if (!self->connected) return; /* disconnect() called from callback */ |
|
1481
|
0 |
0 |
if (self->rbuf_len > 0) |
|
1487
|
0 |
0 |
if (processed > 0 && self->cmd_timer_active) { |
|
|
0 |
0 |
if (processed > 0 && self->cmd_timer_active) { |
|
1488
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) |
|
1503
|
0 |
0 |
if (n > 0) { |
|
1506
|
0 |
0 |
} else if (n == 0) { |
|
1509
|
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) |
|
1518
|
0 |
0 |
while (self->wbuf_off < self->wbuf_len) { |
|
1521
|
0 |
0 |
if (n > 0) { |
|
1523
|
0 |
0 |
} else if (n < 0) { |
|
1524
|
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) |
|
1539
|
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) { |
|
1542
|
0 |
0 |
strerror(err ? err : errno)); |
|
1566
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) return; |
|
1570
|
0 |
0 |
if (self->connecting) { |
|
1571
|
0 |
0 |
if (revents & EV_WRITE) { |
|
1579
|
0 |
0 |
if (revents & EV_READ) { |
|
1581
|
0 |
0 |
if (self->magic != MC_MAGIC_ALIVE) { |
|
1588
|
0 |
0 |
if (revents & EV_WRITE) { |
|
1590
|
0 |
0 |
if (rv < 0) { |
|
1608
|
0 |
0 |
if (self->path) { |
|
1613
|
0 |
0 |
if (strlen(self->path) >= sizeof(addr.sun_path)) { |
|
1620
|
0 |
0 |
if (fd < 0) { |
|
1630
|
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) { |
|
1650
|
0 |
0 |
if (ret != 0) { |
|
1658
|
0 |
0 |
if (fd < 0) { |
|
1669
|
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) { |
|
1688
|
0 |
0 |
if (ret == 0) { |
|
1702
|
0 |
0 |
if (errno != EINPROGRESS) { |
|
1721
|
0 |
0 |
if (self->connect_timeout_ms > 0) { |
|
1738
|
0 |
8 |
I_EV_API("EV::Memcached"); |
|
|
8 |
0 |
I_EV_API("EV::Memcached"); |
|
|
0 |
8 |
I_EV_API("EV::Memcached"); |
|
1752
|
0 |
0 |
if ((items - 1) % 2 != 0) croak("odd number of arguments"); |
|
1779
|
0 |
0 |
for (i = 1; i < items; i += 2) { |
|
1783
|
0 |
0 |
if (strEQ(k, "host")) host_sv = v; |
|
1784
|
0 |
0 |
else if (strEQ(k, "port")) port = SvIV(v); |
|
1785
|
0 |
0 |
else if (strEQ(k, "path")) path_sv = v; |
|
1786
|
0 |
0 |
else if (strEQ(k, "on_error")) { |
|
1787
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_error); |
|
1788
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_error = newSVsv(v); |
|
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_error = newSVsv(v); |
|
1790
|
0 |
0 |
else if (strEQ(k, "on_connect")) { |
|
1791
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_connect = newSVsv(v); |
|
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_connect = newSVsv(v); |
|
1793
|
0 |
0 |
else if (strEQ(k, "on_disconnect")) { |
|
1794
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_disconnect = newSVsv(v); |
|
|
0 |
0 |
if (SvOK(v) && SvROK(v)) RETVAL->on_disconnect = newSVsv(v); |
|
1796
|
0 |
0 |
else if (strEQ(k, "max_pending")) RETVAL->max_pending = SvIV(v); |
|
1797
|
0 |
0 |
else if (strEQ(k, "waiting_timeout")) RETVAL->waiting_timeout_ms = SvIV(v); |
|
1798
|
0 |
0 |
else if (strEQ(k, "connect_timeout")) RETVAL->connect_timeout_ms = SvIV(v); |
|
1799
|
0 |
0 |
else if (strEQ(k, "command_timeout")) RETVAL->command_timeout_ms = SvIV(v); |
|
1800
|
0 |
0 |
else if (strEQ(k, "resume_waiting_on_reconnect")) RETVAL->resume_waiting_on_reconnect = SvTRUE(v) ? 1 : 0; |
|
1801
|
0 |
0 |
else if (strEQ(k, "priority")) RETVAL->priority = SvIV(v); |
|
1802
|
0 |
0 |
else if (strEQ(k, "keepalive")) RETVAL->keepalive = SvIV(v); |
|
1803
|
0 |
0 |
else if (strEQ(k, "reconnect")) do_reconnect = SvTRUE(v) ? 1 : 0; |
|
1804
|
0 |
0 |
else if (strEQ(k, "reconnect_delay")) reconnect_delay = SvIV(v); |
|
1805
|
0 |
0 |
else if (strEQ(k, "max_reconnect_attempts")) max_reconnect_attempts = SvIV(v); |
|
1806
|
0 |
0 |
else if (strEQ(k, "username")) { |
|
1807
|
0 |
0 |
if (SvOK(v)) RETVAL->username = savepv(SvPV_nolen(v)); |
|
1809
|
0 |
0 |
else if (strEQ(k, "password")) { |
|
1810
|
0 |
0 |
if (SvOK(v)) RETVAL->password = savepv(SvPV_nolen(v)); |
|
1812
|
0 |
0 |
else if (strEQ(k, "loop")) { |
|
1817
|
0 |
0 |
if (host_sv && path_sv) { |
|
|
0 |
0 |
if (host_sv && path_sv) { |
|
1820
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_error); |
|
1821
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_connect); |
|
1822
|
0 |
0 |
CLEAR_HANDLER(RETVAL->on_disconnect); |
|
1823
|
0 |
0 |
if (RETVAL->username) Safefree(RETVAL->username); |
|
1824
|
0 |
0 |
if (RETVAL->password) Safefree(RETVAL->password); |
|
1830
|
0 |
0 |
if (do_reconnect) { |
|
1836
|
0 |
0 |
if (host_sv && SvOK(host_sv)) { |
|
|
0 |
0 |
if (host_sv && SvOK(host_sv)) { |
|
1840
|
0 |
0 |
else if (path_sv && SvOK(path_sv)) { |
|
|
0 |
0 |
else if (path_sv && SvOK(path_sv)) { |
|
1852
|
0 |
0 |
if (self->magic == MC_MAGIC_FREED) return; |
|
1856
|
0 |
0 |
if (self->callback_depth > 0) { |
|
1866
|
0 |
0 |
if (self->fd >= 0) { close(self->fd); self->fd = -1; } |
|
1869
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
1875
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue)) { |
|
1884
|
0 |
0 |
CLEAR_HANDLER(self->on_error); |
|
1885
|
0 |
0 |
CLEAR_HANDLER(self->on_connect); |
|
1886
|
0 |
0 |
CLEAR_HANDLER(self->on_disconnect); |
|
1910
|
0 |
0 |
if (!PL_dirty) { |
|
1917
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
1923
|
0 |
0 |
while (!ngx_queue_empty(&self->wait_queue)) { |
|
1933
|
0 |
0 |
CLEAR_HANDLER(self->on_error); |
|
1934
|
0 |
0 |
CLEAR_HANDLER(self->on_connect); |
|
1935
|
0 |
0 |
CLEAR_HANDLER(self->on_disconnect); |
|
1951
|
0 |
0 |
if (self->connected || self->connecting) |
|
|
0 |
0 |
if (self->connected || self->connecting) |
|
1971
|
0 |
0 |
if (self->connected || self->connecting) |
|
|
0 |
0 |
if (self->connected || self->connecting) |
|
1996
|
0 |
0 |
if (self->connected || self->connecting) { |
|
|
0 |
0 |
if (self->connected || self->connecting) { |
|
2008
|
0 |
0 |
RETVAL = self->connected || self->connecting; |
|
|
0 |
0 |
RETVAL = self->connected || self->connecting; |
|
|
0 |
0 |
RETVAL = self->connected || self->connecting; |
|
2016
|
0 |
0 |
if (items > 1) { |
|
2017
|
0 |
0 |
CLEAR_HANDLER(self->on_error); |
|
2018
|
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) { |
|
2022
|
0 |
0 |
RETVAL = self->on_error ? newSVsv(self->on_error) : &PL_sv_undef; |
|
2031
|
0 |
0 |
if (items > 1) { |
|
2032
|
0 |
0 |
CLEAR_HANDLER(self->on_connect); |
|
2033
|
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) { |
|
2037
|
0 |
0 |
RETVAL = self->on_connect ? newSVsv(self->on_connect) : &PL_sv_undef; |
|
2046
|
0 |
0 |
if (items > 1) { |
|
2047
|
0 |
0 |
CLEAR_HANDLER(self->on_disconnect); |
|
2048
|
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) { |
|
2052
|
0 |
0 |
RETVAL = self->on_disconnect ? newSVsv(self->on_disconnect) : &PL_sv_undef; |
|
2065
|
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); |
|
2073
|
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) { |
|
2077
|
0 |
0 |
UV expiry = extra > 0 ? SvUV(ST(3)) : 0; |
|
2078
|
0 |
0 |
UV flags = extra > 1 ? SvUV(ST(4)) : 0; |
|
2086
|
0 |
0 |
if (!cb && ix == 0) { |
|
|
0 |
0 |
if (!cb && ix == 0) { |
|
2099
|
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); |
|
2108
|
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) { |
|
2112
|
0 |
0 |
UV expiry = extra > 0 ? SvUV(ST(4)) : 0; |
|
2113
|
0 |
0 |
UV flags = extra > 1 ? SvUV(ST(5)) : 0; |
|
2129
|
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); |
|
2133
|
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; |
|
2143
|
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); |
|
2147
|
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; |
|
2159
|
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); |
|
2166
|
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) { |
|
2170
|
0 |
0 |
UV delta = extra > 0 ? SvUV(ST(2)) : 1; |
|
2171
|
0 |
0 |
UV initial = extra > 1 ? SvUV(ST(3)) : 0; |
|
2172
|
0 |
0 |
UV expiry = extra > 2 ? SvUV(ST(4)) : 0xFFFFFFFF; |
|
2179
|
0 |
0 |
mc_enqueue_cmd(aTHX_ self, ix == 0 ? MC_OP_INCR : MC_OP_DECR, |
|
2189
|
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); |
|
2194
|
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; |
|
2196
|
0 |
0 |
mc_enqueue_cmd(aTHX_ self, ix == 0 ? MC_OP_APPEND : MC_OP_PREPEND, |
|
2207
|
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); |
|
2211
|
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; |
|
2227
|
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); |
|
2231
|
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) { |
|
2235
|
0 |
0 |
UV expiry = extra > 0 ? SvUV(ST(1)) : 0; |
|
2240
|
0 |
0 |
if (expiry > 0) { |
|
2246
|
0 |
0 |
if (cb) |
|
2261
|
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); |
|
2263
|
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; |
|
2276
|
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); |
|
2280
|
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) { |
|
2287
|
0 |
0 |
if (extra > 0 && SvOK(ST(1))) { |
|
|
0 |
0 |
if (extra > 0 && SvOK(ST(1))) { |
|
2301
|
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); |
|
2303
|
0 |
0 |
if (!SvROK(keys_sv) || SvTYPE(SvRV(keys_sv)) != SVt_PVAV) |
|
|
0 |
0 |
if (!SvROK(keys_sv) || SvTYPE(SvRV(keys_sv)) != SVt_PVAV) |
|
2306
|
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; |
|
2316
|
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); |
|
2321
|
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; |
|
2340
|
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); |
|
2342
|
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; |
|
2351
|
0 |
0 |
RETVAL = self->pending_count; |
|
2358
|
0 |
0 |
RETVAL = self->waiting_count; |
|
2366
|
0 |
0 |
if (items > 1) { |
|
2369
|
0 |
0 |
if (self->max_pending < 0) self->max_pending = 0; |
|
2371
|
0 |
0 |
if (self->connected && self->max_pending > old) |
|
|
0 |
0 |
if (self->connected && self->max_pending > old) |
|
2374
|
0 |
0 |
RETVAL = self->max_pending; |
|
2383
|
0 |
0 |
if (items > 1) { |
|
2385
|
0 |
0 |
if (self->waiting_timeout_ms < 0) self->waiting_timeout_ms = 0; |
|
2387
|
0 |
0 |
RETVAL = self->waiting_timeout_ms; |
|
2396
|
0 |
0 |
if (items > 1) { |
|
2399
|
0 |
0 |
RETVAL = self->resume_waiting_on_reconnect; |
|
2408
|
0 |
0 |
if (items > 1) { |
|
2410
|
0 |
0 |
if (self->connect_timeout_ms < 0) self->connect_timeout_ms = 0; |
|
2412
|
0 |
0 |
RETVAL = self->connect_timeout_ms; |
|
2421
|
0 |
0 |
if (items > 1) { |
|
2423
|
0 |
0 |
if (self->command_timeout_ms < 0) self->command_timeout_ms = 0; |
|
2424
|
0 |
0 |
if (self->command_timeout_ms == 0) |
|
2426
|
0 |
0 |
else if (!ngx_queue_empty(&self->cb_queue)) |
|
2429
|
0 |
0 |
RETVAL = self->command_timeout_ms; |
|
2441
|
0 |
0 |
if (!enable) { |
|
2450
|
0 |
0 |
RETVAL = self->reconnect; |
|
2458
|
0 |
0 |
if (items > 1) { |
|
2460
|
0 |
0 |
if (self->priority < -2) self->priority = -2; |
|
2461
|
0 |
0 |
if (self->priority > 2) self->priority = 2; |
|
2463
|
0 |
0 |
if (self->reading) { |
|
2470
|
0 |
0 |
if (self->writing) { |
|
2478
|
0 |
0 |
RETVAL = self->priority; |
|
2487
|
0 |
0 |
if (items > 1) { |
|
2489
|
0 |
0 |
if (self->keepalive < 0) self->keepalive = 0; |
|
2490
|
0 |
0 |
if (self->connected && self->fd >= 0) |
|
|
0 |
0 |
if (self->connected && self->fd >= 0) |
|
2493
|
0 |
0 |
RETVAL = self->keepalive; |