CPINLINE int CP_CLIENT_SERIALIZE_SEND_MEM(zval *ret_value, cpClient *cli) { int pipe_fd_write = get_writefd(CONN(cli)->worker_id); instead_smart dest; dest.len = 0; dest.addr = get_attach_buf(CONN(cli)->worker_id, CPGS->max_buffer_len, CPGS->G[CONN(cli)->group_id].workers[CONN(cli)->worker_index].sm_obj.mmap_name); dest.max = CPGS->max_buffer_len; dest.exceed = 0; php_msgpack_serialize(&dest, ret_value); if (dest.exceed == 1) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "data is exceed,increase max_read_len Error: %s [%d] ", strerror(errno), errno); } else { cpWorkerInfo worker_event; worker_event.len = dest.len; worker_event.pid = cpPid; worker_event.type = 0; //暫時沒用 int ret = write(pipe_fd_write, &worker_event, sizeof (worker_event)); if (ret == -1) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "write error Error: %s [%d]", strerror(errno), errno); } return SUCCESS; } return FAILURE; }
CPINLINE int CP_CLIENT_SERIALIZE_SEND_MEM(zval *ret_value, int worker_id, int max, char *mm_name) { int pipe_fd_write = get_writefd(worker_id); instead_smart dest; dest.len = 0; dest.addr = get_attach_buf(worker_id, max, mm_name); dest.max = max; dest.exceed = 0; php_msgpack_serialize(&dest, ret_value); if (dest.exceed == 1) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "data is exceed,increase max_read_len Error: %s [%d] ", strerror(errno), errno); } else { cpWorkerInfo worker_event; worker_event.len = dest.len; worker_event.pid = cpPid; worker_event.type = 0; //暫時沒用 int ret = write(pipe_fd_write, &worker_event, sizeof (worker_event)); if (ret == -1) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "write error Error: %s [%d]", strerror(errno), errno); } return SUCCESS; } return FAILURE; }
CPINLINE int CP_CLIENT_SERIALIZE_SEND_MEM(zval *ret_value, int worker_id, int max, int semid) { int pipe_fd_write = get_writefd(worker_id); instead_smart dest; dest.len = 0; dest.addr = get_attach_buf(worker_id,semid); dest.max = max; dest.exceed = '0'; php_msgpack_serialize(&dest, ret_value); if (dest.exceed == '1') { zend_error(E_ERROR, "data is exceed,increase max_read_len"); } else { cpWorkerInfo worker_event; worker_event.len = dest.len; worker_event.pid = cpPid; worker_event.type = 0; //暫時沒用 int ret = write(pipe_fd_write, &worker_event, sizeof (worker_event)); if (ret == -1) { zend_error(E_ERROR, "write error Error: %s [%d]", strerror(errno), errno); } return SUCCESS; } }
int php_yar_packager_msgpack_pack(yar_packager_t *self, zval *pzval, smart_str *buf, char **msg) /* {{{ */ { php_msgpack_serialize(buf, pzval); return 1; } /* }}} */