|
@@ -41,11 +41,13 @@ uint8_t num = 0; |
|
|
|
|
|
|
|
|
PHP_INI_BEGIN() |
|
|
PHP_INI_BEGIN() |
|
|
STD_PHP_INI_ENTRY("snowdrift.Method", "1", PHP_INI_SYSTEM, OnUpdateLongGEZero, Method, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.Method", "1", PHP_INI_SYSTEM, OnUpdateLongGEZero, Method, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.BaseTime", "1577808000000", PHP_INI_SYSTEM, OnUpdateLongGEZero, BaseTime, zend_snowdrift_globals, snowdrift_globals) |
|
|
|
|
|
|
|
|
STD_PHP_INI_ENTRY("snowdrift.BaseTime", "1582136402000", PHP_INI_SYSTEM, OnUpdateLongGEZero, BaseTime, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.WorkerId", "1", PHP_INI_SYSTEM, OnUpdateLongGEZero, WorkerId, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.WorkerId", "1", PHP_INI_SYSTEM, OnUpdateLongGEZero, WorkerId, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.WorkerIdNum", "1", PHP_INI_SYSTEM, OnUpdateLongGEZero, WorkerIdNum, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.WorkerIdNum", "1", PHP_INI_SYSTEM, OnUpdateLongGEZero, WorkerIdNum, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.WorkerIdBitLength", "6", PHP_INI_SYSTEM, OnUpdateLongGEZero, WorkerIdBitLength, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.WorkerIdBitLength", "6", PHP_INI_SYSTEM, OnUpdateLongGEZero, WorkerIdBitLength, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.SeqBitLength", "6", PHP_INI_SYSTEM, OnUpdateLongGEZero, SeqBitLength, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.SeqBitLength", "6", PHP_INI_SYSTEM, OnUpdateLongGEZero, SeqBitLength, zend_snowdrift_globals, snowdrift_globals) |
|
|
|
|
|
STD_PHP_INI_ENTRY("snowdrift.MaxSeqNumber", "0", PHP_INI_SYSTEM, OnUpdateLongGEZero, MaxSeqNumber, zend_snowdrift_globals, snowdrift_globals) |
|
|
|
|
|
STD_PHP_INI_ENTRY("snowdrift.MinSeqNumber", "0", PHP_INI_SYSTEM, OnUpdateLongGEZero, MinSeqNumber, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.TopOverCostCount", "2000", PHP_INI_SYSTEM, OnUpdateLongGEZero, TopOverCostCount, zend_snowdrift_globals, snowdrift_globals) |
|
|
STD_PHP_INI_ENTRY("snowdrift.TopOverCostCount", "2000", PHP_INI_SYSTEM, OnUpdateLongGEZero, TopOverCostCount, zend_snowdrift_globals, snowdrift_globals) |
|
|
PHP_INI_END() |
|
|
PHP_INI_END() |
|
|
|
|
|
|
|
@@ -62,6 +64,12 @@ static int snowdrift_init() |
|
|
if (shm_alloc(&shmctx) == -1) |
|
|
if (shm_alloc(&shmctx) == -1) |
|
|
{ |
|
|
{ |
|
|
zend_throw_exception_ex(NULL, 0, "shared memory malloc failed"); |
|
|
zend_throw_exception_ex(NULL, 0, "shared memory malloc failed"); |
|
|
|
|
|
RETURN_FALSE; |
|
|
|
|
|
} |
|
|
|
|
|
if (SD_G(MaxSeqNumber) <= SD_G(MinSeqNumber)) |
|
|
|
|
|
{ |
|
|
|
|
|
zend_throw_exception_ex(NULL, 0, "MaxSeqNumber must GE then MinSeqNumber"); |
|
|
|
|
|
RETURN_FALSE; |
|
|
} |
|
|
} |
|
|
bzero(shmctx.addr, num * sizeof(snowflake)); |
|
|
bzero(shmctx.addr, num * sizeof(snowflake)); |
|
|
sf = (snowflake *)shmctx.addr; |
|
|
sf = (snowflake *)shmctx.addr; |
|
@@ -73,6 +81,8 @@ static int snowdrift_init() |
|
|
tmp->WorkerId = i + 1; |
|
|
tmp->WorkerId = i + 1; |
|
|
tmp->WorkerIdBitLength = SD_G(WorkerIdBitLength); |
|
|
tmp->WorkerIdBitLength = SD_G(WorkerIdBitLength); |
|
|
tmp->SeqBitLength = SD_G(SeqBitLength); |
|
|
tmp->SeqBitLength = SD_G(SeqBitLength); |
|
|
|
|
|
tmp->MaxSeqNumber = SD_G(MaxSeqNumber); |
|
|
|
|
|
tmp->MinSeqNumber = SD_G(MinSeqNumber); |
|
|
tmp->TopOverCostCount = SD_G(TopOverCostCount); |
|
|
tmp->TopOverCostCount = SD_G(TopOverCostCount); |
|
|
Config(tmp); |
|
|
Config(tmp); |
|
|
} |
|
|
} |
|
|