@@ -474,51 +474,48 @@ typedef enum _PUBSUB_TYPE {
474
474
#define IF_PIPELINE () if (redis_sock->mode == PIPELINE)
475
475
#define IF_NOT_PIPELINE () if (redis_sock->mode != PIPELINE)
476
476
477
- #define PIPELINE_ENQUEUE_COMMAND (cmd , cmd_len ) request_item *tmp; \
478
- struct request_item *current_request;\
479
- tmp = malloc(sizeof(request_item));\
477
+ #define PIPELINE_ENQUEUE_COMMAND (cmd , cmd_len ) do { \
478
+ request_item *tmp = malloc(sizeof(request_item)); \
480
479
tmp->request_str = calloc(cmd_len, 1);\
481
480
memcpy(tmp->request_str, cmd, cmd_len);\
482
481
tmp->request_size = cmd_len;\
483
482
tmp->next = NULL;\
484
- current_request = redis_sock->pipeline_current; \
485
- if(current_request) {\
486
- current_request->next = tmp;\
483
+ if (redis_sock->pipeline_current) { \
484
+ redis_sock->pipeline_current->next = tmp; \
487
485
} \
488
486
redis_sock->pipeline_current = tmp; \
489
487
if(NULL == redis_sock->pipeline_head) { \
490
488
redis_sock->pipeline_head = redis_sock->pipeline_current;\
491
- }
489
+ } \
490
+ } while (0)
492
491
493
492
#define SOCKET_WRITE_COMMAND (redis_sock , cmd , cmd_len ) \
494
493
if(redis_sock_write(redis_sock, cmd, cmd_len TSRMLS_CC) < 0) { \
495
494
efree(cmd); \
496
495
RETURN_FALSE; \
497
496
}
498
497
499
- #define REDIS_SAVE_CALLBACK (callback , closure_context ) \
500
- IF_NOT_ATOMIC() { \
501
- fold_item *f1, *current; \
502
- f1 = malloc(sizeof(fold_item)); \
503
- f1->fun = (void *)callback; \
504
- f1->ctx = closure_context; \
505
- f1->next = NULL; \
506
- current = redis_sock->current;\
507
- if(current) current->next = f1; \
508
- redis_sock->current = f1; \
509
- if(NULL == redis_sock->head) { \
510
- redis_sock->head = redis_sock->current;\
511
- }\
512
- }
498
+ #define REDIS_SAVE_CALLBACK (callback , closure_context ) do { \
499
+ fold_item *f1 = malloc(sizeof(fold_item)); \
500
+ f1->fun = (void *)callback; \
501
+ f1->ctx = closure_context; \
502
+ f1->next = NULL; \
503
+ if (redis_sock->current) { \
504
+ redis_sock->current->next = f1; \
505
+ } \
506
+ redis_sock->current = f1; \
507
+ if (NULL == redis_sock->head) { \
508
+ redis_sock->head = redis_sock->current; \
509
+ } \
510
+ } while (0)
513
511
514
512
#define REDIS_ELSE_IF_MULTI (function , closure_context ) \
515
513
else IF_MULTI() { \
516
- if(redis_response_enqueued(redis_sock TSRMLS_CC) == 1) {\
517
- REDIS_SAVE_CALLBACK(function, closure_context); \
518
- RETURN_ZVAL(getThis(), 1, 0);\
519
- } else {\
520
- RETURN_FALSE;\
521
- }\
514
+ if (redis_response_enqueued(redis_sock TSRMLS_CC) != SUCCESS) { \
515
+ RETURN_FALSE; \
516
+ } \
517
+ REDIS_SAVE_CALLBACK(function, closure_context); \
518
+ RETURN_ZVAL(getThis(), 1, 0);\
522
519
}
523
520
524
521
#define REDIS_ELSE_IF_PIPELINE (function , closure_context ) \
0 commit comments