123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- /*
- * Gearman PHP Extension
- *
- * Copyright (C) 2008 James M. Luedke <contact@jamesluedke.com>,
- * Eric Day <eday@oddments.org>
- * All rights reserved.
- *
- * Use and distribution licensed under the PHP license. See
- * the LICENSE file in this directory for full text.
- */
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include "php.h"
- #include "php_ini.h"
- #include "ext/standard/info.h"
- #include "php_gearman.h"
- #include "php_gearman_client.h"
- #include "php_gearman_task.h"
- #include "php_gearman_worker.h"
- #include "zend_exceptions.h"
- #include "zend_interfaces.h"
- #include "gearman_arginfo.h"
- #include <libgearman-1.0/gearman.h>
- #include <libgearman-1.0/interface/status.h>
- #include <libgearman-1.0/status.h>
- zend_class_entry *gearman_exception_ce;
- zend_class_entry *gearman_client_ce;
- zend_object_handlers gearman_client_obj_handlers;
- zend_class_entry *gearman_task_ce;
- zend_object_handlers gearman_task_obj_handlers;
- zend_class_entry *gearman_job_ce;
- zend_object_handlers gearman_job_obj_handlers;
- zend_class_entry *gearman_worker_ce;
- zend_object_handlers gearman_worker_obj_handlers;
- /* Custom malloc and free calls to avoid excessive buffer copies. */
- void *_php_malloc(size_t size, void *arg) {
- uint8_t *ret;
- ret = emalloc(size+1);
- ret[size]= 0;
- return ret;
- }
- void _php_free(void *ptr, void *arg) {
- efree(ptr);
- }
- /*
- * Functions from gearman.h
- */
- /* {{{ proto string gearman_version()
- Returns libgearman version */
- PHP_FUNCTION(gearman_version) {
- RETURN_STRING((char *)gearman_version());
- }
- /* }}} */
- /* {{{ proto string gearman_bugreport()
- Returns bug report URL string */
- PHP_FUNCTION(gearman_bugreport) {
- RETURN_STRING((char *)gearman_bugreport());
- }
- /* }}} */
- /* {{{ proto ?string gearman_verbose_name(constant verbose)
- Returns string with the name of the given verbose level */
- PHP_FUNCTION(gearman_verbose_name) {
- zend_long verbose;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l",
- &verbose) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Unable to parse parameters.");
- RETURN_NULL();
- }
- if (verbose < 0) {
- php_error_docref(NULL, E_WARNING, "Input must be an integer greater than 0.");
- RETURN_NULL();
- }
- RETURN_STRING((char *)gearman_verbose_name(verbose));
- }
- /* }}} */
- PHP_MINIT_FUNCTION(gearman) {
- zend_class_entry ce;
- INIT_CLASS_ENTRY(ce, "GearmanClient", class_GearmanClient_methods);
- gearman_client_ce = zend_register_internal_class(&ce);
- gearman_client_ce->create_object = gearman_client_obj_new;
- memcpy(&gearman_client_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_client_obj_handlers));
- gearman_client_obj_handlers.offset = XtOffsetOf(gearman_client_obj, std);
- gearman_client_obj_handlers.free_obj = gearman_client_free_obj;
- INIT_CLASS_ENTRY(ce, "GearmanTask", class_GearmanTask_methods);
- gearman_task_ce = zend_register_internal_class(&ce);
- gearman_task_ce->create_object = gearman_task_obj_new;
- memcpy(&gearman_task_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_task_obj_handlers));
- gearman_task_obj_handlers.offset = XtOffsetOf(gearman_task_obj, std);
- gearman_task_obj_handlers.free_obj = gearman_task_free_obj;
- INIT_CLASS_ENTRY(ce, "GearmanWorker", class_GearmanWorker_methods);
- gearman_worker_ce = zend_register_internal_class(&ce);
- gearman_worker_ce->create_object = gearman_worker_obj_new;
- memcpy(&gearman_worker_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_worker_obj_handlers));
- gearman_worker_obj_handlers.offset = XtOffsetOf(gearman_worker_obj, std);
- INIT_CLASS_ENTRY(ce, "GearmanJob", class_GearmanJob_methods);
- gearman_job_ce = zend_register_internal_class(&ce);
- gearman_job_ce->create_object = gearman_job_obj_new;
- memcpy(&gearman_job_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_job_obj_handlers));
- gearman_job_obj_handlers.offset = XtOffsetOf(gearman_job_obj, std);
- /* XXX exception class */
- INIT_CLASS_ENTRY(ce, "GearmanException", class_GearmanException_methods)
- gearman_exception_ce = zend_register_internal_class_ex(&ce, zend_exception_get_default());
- gearman_exception_ce->ce_flags |= ZEND_ACC_FINAL;
- zend_declare_property_long(gearman_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC);
- /* These are automatically generated from gearman_constants.h using
- const_gen.sh. Do not remove the CONST_GEN_* comments, this is how the
- script locates the correct location to replace. */
- /* CONST_GEN_START */
- REGISTER_STRING_CONSTANT("GEARMAN_DEFAULT_TCP_HOST",
- GEARMAN_DEFAULT_TCP_HOST,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_TCP_PORT",
- GEARMAN_DEFAULT_TCP_PORT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_SOCKET_TIMEOUT",
- GEARMAN_DEFAULT_SOCKET_TIMEOUT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_SOCKET_SEND_SIZE",
- GEARMAN_DEFAULT_SOCKET_SEND_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_SOCKET_RECV_SIZE",
- GEARMAN_DEFAULT_SOCKET_RECV_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_MAX_ERROR_SIZE",
- GEARMAN_MAX_ERROR_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_PACKET_HEADER_SIZE",
- GEARMAN_PACKET_HEADER_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_HANDLE_SIZE",
- GEARMAN_JOB_HANDLE_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_OPTION_SIZE",
- GEARMAN_OPTION_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_UNIQUE_SIZE",
- GEARMAN_UNIQUE_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_MAX_COMMAND_ARGS",
- GEARMAN_MAX_COMMAND_ARGS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_ARGS_BUFFER_SIZE",
- GEARMAN_ARGS_BUFFER_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SEND_BUFFER_SIZE",
- GEARMAN_SEND_BUFFER_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_RECV_BUFFER_SIZE",
- GEARMAN_RECV_BUFFER_SIZE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_WAIT_TIMEOUT",
- GEARMAN_WORKER_WAIT_TIMEOUT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SUCCESS",
- GEARMAN_SUCCESS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_IO_WAIT",
- GEARMAN_IO_WAIT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SHUTDOWN",
- GEARMAN_SHUTDOWN,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SHUTDOWN_GRACEFUL",
- GEARMAN_SHUTDOWN_GRACEFUL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_ERRNO",
- GEARMAN_ERRNO,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_EVENT",
- GEARMAN_EVENT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TOO_MANY_ARGS",
- GEARMAN_TOO_MANY_ARGS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NO_ACTIVE_FDS",
- GEARMAN_NO_ACTIVE_FDS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_INVALID_MAGIC",
- GEARMAN_INVALID_MAGIC,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_INVALID_COMMAND",
- GEARMAN_INVALID_COMMAND,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_INVALID_PACKET",
- GEARMAN_INVALID_PACKET,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_UNEXPECTED_PACKET",
- GEARMAN_UNEXPECTED_PACKET,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_GETADDRINFO",
- GEARMAN_GETADDRINFO,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NO_SERVERS",
- GEARMAN_NO_SERVERS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_LOST_CONNECTION",
- GEARMAN_LOST_CONNECTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_MEMORY_ALLOCATION_FAILURE",
- GEARMAN_MEMORY_ALLOCATION_FAILURE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_EXISTS",
- GEARMAN_JOB_EXISTS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_QUEUE_FULL",
- GEARMAN_JOB_QUEUE_FULL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SERVER_ERROR",
- GEARMAN_SERVER_ERROR,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORK_ERROR",
- GEARMAN_WORK_ERROR,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORK_DATA",
- GEARMAN_WORK_DATA,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORK_WARNING",
- GEARMAN_WORK_WARNING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORK_STATUS",
- GEARMAN_WORK_STATUS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORK_EXCEPTION",
- GEARMAN_WORK_EXCEPTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORK_FAIL",
- GEARMAN_WORK_FAIL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NOT_CONNECTED",
- GEARMAN_NOT_CONNECTED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COULD_NOT_CONNECT",
- GEARMAN_COULD_NOT_CONNECT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SEND_IN_PROGRESS",
- GEARMAN_SEND_IN_PROGRESS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_RECV_IN_PROGRESS",
- GEARMAN_RECV_IN_PROGRESS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NOT_FLUSHING",
- GEARMAN_NOT_FLUSHING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_DATA_TOO_LARGE",
- GEARMAN_DATA_TOO_LARGE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_INVALID_FUNCTION_NAME",
- GEARMAN_INVALID_FUNCTION_NAME,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_INVALID_WORKER_FUNCTION",
- GEARMAN_INVALID_WORKER_FUNCTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NO_REGISTERED_FUNCTIONS",
- GEARMAN_NO_REGISTERED_FUNCTIONS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NO_JOBS",
- GEARMAN_NO_JOBS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_ECHO_DATA_CORRUPTION",
- GEARMAN_ECHO_DATA_CORRUPTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NEED_WORKLOAD_FN",
- GEARMAN_NEED_WORKLOAD_FN,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_PAUSE",
- GEARMAN_PAUSE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_UNKNOWN_STATE",
- GEARMAN_UNKNOWN_STATE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_PTHREAD",
- GEARMAN_PTHREAD,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_PIPE_EOF",
- GEARMAN_PIPE_EOF,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_QUEUE_ERROR",
- GEARMAN_QUEUE_ERROR,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_FLUSH_DATA",
- GEARMAN_FLUSH_DATA,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_SEND_BUFFER_TOO_SMALL",
- GEARMAN_SEND_BUFFER_TOO_SMALL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_IGNORE_PACKET",
- GEARMAN_IGNORE_PACKET,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_UNKNOWN_OPTION",
- GEARMAN_UNKNOWN_OPTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TIMEOUT",
- GEARMAN_TIMEOUT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_MAX_RETURN",
- GEARMAN_MAX_RETURN,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_FATAL",
- GEARMAN_VERBOSE_FATAL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_ERROR",
- GEARMAN_VERBOSE_ERROR,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_INFO",
- GEARMAN_VERBOSE_INFO,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_DEBUG",
- GEARMAN_VERBOSE_DEBUG,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_CRAZY",
- GEARMAN_VERBOSE_CRAZY,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_MAX",
- GEARMAN_VERBOSE_MAX,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_NON_BLOCKING",
- GEARMAN_NON_BLOCKING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_DONT_TRACK_PACKETS",
- GEARMAN_DONT_TRACK_PACKETS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_READY",
- GEARMAN_CON_READY,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_PACKET_IN_USE",
- GEARMAN_CON_PACKET_IN_USE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_EXTERNAL_FD",
- GEARMAN_CON_EXTERNAL_FD,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_IGNORE_LOST_CONNECTION",
- GEARMAN_CON_IGNORE_LOST_CONNECTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_CLOSE_AFTER_FLUSH",
- GEARMAN_CON_CLOSE_AFTER_FLUSH,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_SEND_STATE_NONE",
- GEARMAN_CON_SEND_STATE_NONE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CON_RECV_STATE_READ_DATA",
- GEARMAN_CON_RECV_STATE_READ_DATA,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_TEXT",
- GEARMAN_COMMAND_TEXT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_CAN_DO",
- GEARMAN_COMMAND_CAN_DO,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_CANT_DO",
- GEARMAN_COMMAND_CANT_DO,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_RESET_ABILITIES",
- GEARMAN_COMMAND_RESET_ABILITIES,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_PRE_SLEEP",
- GEARMAN_COMMAND_PRE_SLEEP,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_UNUSED",
- GEARMAN_COMMAND_UNUSED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_NOOP",
- GEARMAN_COMMAND_NOOP,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB",
- GEARMAN_COMMAND_SUBMIT_JOB,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_JOB_CREATED",
- GEARMAN_COMMAND_JOB_CREATED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_GRAB_JOB",
- GEARMAN_COMMAND_GRAB_JOB,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_NO_JOB",
- GEARMAN_COMMAND_NO_JOB,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_JOB_ASSIGN",
- GEARMAN_COMMAND_JOB_ASSIGN,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_STATUS",
- GEARMAN_COMMAND_WORK_STATUS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_COMPLETE",
- GEARMAN_COMMAND_WORK_COMPLETE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_FAIL",
- GEARMAN_COMMAND_WORK_FAIL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_GET_STATUS",
- GEARMAN_COMMAND_GET_STATUS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ECHO_REQ",
- GEARMAN_COMMAND_ECHO_REQ,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ECHO_RES",
- GEARMAN_COMMAND_ECHO_RES,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_BG",
- GEARMAN_COMMAND_SUBMIT_JOB_BG,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ERROR",
- GEARMAN_COMMAND_ERROR,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_STATUS_RES",
- GEARMAN_COMMAND_STATUS_RES,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_HIGH",
- GEARMAN_COMMAND_SUBMIT_JOB_HIGH,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SET_CLIENT_ID",
- GEARMAN_COMMAND_SET_CLIENT_ID,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_CAN_DO_TIMEOUT",
- GEARMAN_COMMAND_CAN_DO_TIMEOUT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ALL_YOURS",
- GEARMAN_COMMAND_ALL_YOURS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_EXCEPTION",
- GEARMAN_COMMAND_WORK_EXCEPTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_OPTION_REQ",
- GEARMAN_COMMAND_OPTION_REQ,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_OPTION_RES",
- GEARMAN_COMMAND_OPTION_RES,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_DATA",
- GEARMAN_COMMAND_WORK_DATA,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_WARNING",
- GEARMAN_COMMAND_WORK_WARNING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_GRAB_JOB_UNIQ",
- GEARMAN_COMMAND_GRAB_JOB_UNIQ,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_JOB_ASSIGN_UNIQ",
- GEARMAN_COMMAND_JOB_ASSIGN_UNIQ,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG",
- GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_LOW",
- GEARMAN_COMMAND_SUBMIT_JOB_LOW,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG",
- GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_SCHED",
- GEARMAN_COMMAND_SUBMIT_JOB_SCHED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_EPOCH",
- GEARMAN_COMMAND_SUBMIT_JOB_EPOCH,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_MAX",
- GEARMAN_COMMAND_MAX,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_NEW",
- GEARMAN_TASK_STATE_NEW,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_SUBMIT",
- GEARMAN_TASK_STATE_SUBMIT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_WORKLOAD",
- GEARMAN_TASK_STATE_WORKLOAD,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_WORK",
- GEARMAN_TASK_STATE_WORK,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_CREATED",
- GEARMAN_TASK_STATE_CREATED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_DATA",
- GEARMAN_TASK_STATE_DATA,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_WARNING",
- GEARMAN_TASK_STATE_WARNING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_STATUS",
- GEARMAN_TASK_STATE_STATUS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_COMPLETE",
- GEARMAN_TASK_STATE_COMPLETE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_EXCEPTION",
- GEARMAN_TASK_STATE_EXCEPTION,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_FAIL",
- GEARMAN_TASK_STATE_FAIL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_FINISHED",
- GEARMAN_TASK_STATE_FINISHED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_HIGH",
- GEARMAN_JOB_PRIORITY_HIGH,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_NORMAL",
- GEARMAN_JOB_PRIORITY_NORMAL,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_LOW",
- GEARMAN_JOB_PRIORITY_LOW,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_MAX",
- GEARMAN_JOB_PRIORITY_MAX,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_ALLOCATED",
- GEARMAN_CLIENT_ALLOCATED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_NON_BLOCKING",
- GEARMAN_CLIENT_NON_BLOCKING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_TASK_IN_USE",
- GEARMAN_CLIENT_TASK_IN_USE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_UNBUFFERED_RESULT",
- GEARMAN_CLIENT_UNBUFFERED_RESULT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_NO_NEW",
- GEARMAN_CLIENT_NO_NEW,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_FREE_TASKS",
- GEARMAN_CLIENT_FREE_TASKS,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_IDLE",
- GEARMAN_CLIENT_STATE_IDLE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_NEW",
- GEARMAN_CLIENT_STATE_NEW,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_SUBMIT",
- GEARMAN_CLIENT_STATE_SUBMIT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_PACKET",
- GEARMAN_CLIENT_STATE_PACKET,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_ALLOCATED",
- GEARMAN_WORKER_ALLOCATED,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_NON_BLOCKING",
- GEARMAN_WORKER_NON_BLOCKING,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_PACKET_INIT",
- GEARMAN_WORKER_PACKET_INIT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_GRAB_JOB_IN_USE",
- GEARMAN_WORKER_GRAB_JOB_IN_USE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_PRE_SLEEP_IN_USE",
- GEARMAN_WORKER_PRE_SLEEP_IN_USE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_WORK_JOB_IN_USE",
- GEARMAN_WORKER_WORK_JOB_IN_USE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_CHANGE",
- GEARMAN_WORKER_CHANGE,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_GRAB_UNIQ",
- GEARMAN_WORKER_GRAB_UNIQ,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_TIMEOUT_RETURN",
- GEARMAN_WORKER_TIMEOUT_RETURN,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_START",
- GEARMAN_WORKER_STATE_START,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_FUNCTION_SEND",
- GEARMAN_WORKER_STATE_FUNCTION_SEND,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_CONNECT",
- GEARMAN_WORKER_STATE_CONNECT,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_GRAB_JOB_SEND",
- GEARMAN_WORKER_STATE_GRAB_JOB_SEND,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_GRAB_JOB_RECV",
- GEARMAN_WORKER_STATE_GRAB_JOB_RECV,
- CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_PRE_SLEEP",
- GEARMAN_WORKER_STATE_PRE_SLEEP,
- CONST_CS | CONST_PERSISTENT);
- /* CONST_GEN_STOP */
- return SUCCESS;
- }
- PHP_MSHUTDOWN_FUNCTION(gearman) {
- return SUCCESS;
- }
- PHP_MINFO_FUNCTION(gearman) {
- char port_str[6];
- php_info_print_table_start();
- php_info_print_table_header(2, "gearman support", "enabled");
- php_info_print_table_row(2, "extension version", PHP_GEARMAN_VERSION);
- php_info_print_table_row(2, "libgearman version", gearman_version());
- php_info_print_table_row(2, "Default TCP Host", GEARMAN_DEFAULT_TCP_HOST);
- snprintf(port_str, 6, "%u", GEARMAN_DEFAULT_TCP_PORT);
- php_info_print_table_row(2, "Default TCP Port", port_str);
- php_info_print_table_end();
- }
- /* Module config struct. */
- zend_module_entry gearman_module_entry = {
- STANDARD_MODULE_HEADER,
- "gearman",
- ext_functions,
- PHP_MINIT(gearman),
- PHP_MSHUTDOWN(gearman),
- NULL,
- NULL,
- PHP_MINFO(gearman),
- PHP_GEARMAN_VERSION,
- STANDARD_MODULE_PROPERTIES
- };
- #ifdef COMPILE_DL_GEARMAN
- ZEND_GET_MODULE(gearman)
- #endif
|