[prev in list] [next in list] [prev in thread] [next in thread]
List: pecl-cvs
Subject: [PECL-CVS] =?utf-8?q?svn:_/pecl/mysqlnd=5Fms/trunk/_mysqlnd=5Fms=5Ffilter=5Frandom.c?=
From: Andrey_Hristov <andrey () php ! net>
Date: 2011-09-27 10:39:40
Message-ID: svn-andrey-1317119980-317385-1327837379 () svn ! php ! net
[Download RAW message or body]
andrey Tue, 27 Sep 2011 10:39:40 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=317385
Log:
Refactor the code a bit, so it is more readable
Changed paths:
U pecl/mysqlnd_ms/trunk/mysqlnd_ms_filter_random.c
Modified: pecl/mysqlnd_ms/trunk/mysqlnd_ms_filter_random.c
===================================================================
--- pecl/mysqlnd_ms/trunk/mysqlnd_ms_filter_random.c 2011-09-27 10:31:32 UTC (rev \
317384)
+++ pecl/mysqlnd_ms/trunk/mysqlnd_ms_filter_random.c 2011-09-27 10:39:40 UTC (rev \
317385) @@ -134,29 +134,26 @@
DBG_RETURN(NULL);
}
} else {
- if (CONN_GET_STATE(connection) == CONN_ALLOCED &&
- PASS != mysqlnd_ms_lazy_connect(element, FALSE TSRMLS_CC))
- {
- smart_str_free(&fprint);
- if (SERVER_FAILOVER_DISABLED == stgy->failover_strategy) {
- /* no failover */
- DBG_INF("Failover disabled");
- DBG_RETURN(connection);
+ if (CONN_GET_STATE(connection) > CONN_ALLOCED || PASS == \
mysqlnd_ms_lazy_connect(element, FALSE TSRMLS_CC)) { \
+ MYSQLND_MS_INC_STATISTIC(MS_STAT_USE_SLAVE); \
+ SET_EMPTY_ERROR(connection->error_info); + if (TRUE == \
filter->sticky.once) { + zend_hash_update(&filter->sticky.slave_context, \
fprint.c, fprint.len /*\0 counted*/, &connection, + sizeof(MYSQLND *), \
NULL); }
- goto fallthrough;
+ smart_str_free(&fprint);
+ DBG_RETURN(connection);
}
- MYSQLND_MS_INC_STATISTIC(MS_STAT_USE_SLAVE);
- if (TRUE == filter->sticky.once) {
- zend_hash_update(&filter->sticky.slave_context, fprint.c, fprint.len /*\0 \
counted*/, &connection,
- sizeof(MYSQLND *), NULL);
- }
smart_str_free(&fprint);
- SET_EMPTY_ERROR(connection->error_info);
- DBG_RETURN(connection);
+ if (SERVER_FAILOVER_DISABLED == stgy->failover_strategy) {
+ /* no failover */
+ DBG_INF("Failover disabled");
+ DBG_RETURN(connection);
+ }
+ /* falling-through */
}
}/* switch (zend_hash_find) */
}
-fallthrough:
DBG_INF("FAIL-OVER");
/* fall-through */
case USE_MASTER:
@@ -204,19 +201,14 @@
connection = (element_pp && (element = *element_pp) && element->conn) ? \
element->conn : NULL;
if (connection) {
- do {
- if (CONN_GET_STATE(connection) == CONN_ALLOCED &&
- PASS != mysqlnd_ms_lazy_connect(element, TRUE TSRMLS_CC))
- {
- break;
- }
+ if (CONN_GET_STATE(connection) > CONN_ALLOCED || PASS == \
mysqlnd_ms_lazy_connect(element, TRUE TSRMLS_CC)) { \
MYSQLND_MS_INC_STATISTIC(MS_STAT_USE_MASTER); \
SET_EMPTY_ERROR(connection->error_info); if (TRUE == filter->sticky.once) {
zend_hash_update(&filter->sticky.master_context, fprint.c, fprint.len /*\0 \
counted*/, &connection, sizeof(MYSQLND *), NULL);
}
- } while (0);
+ }
} else {
char error_buf[256];
snprintf(error_buf, sizeof(error_buf), MYSQLND_MS_ERROR_PREFIX " Couldn't find \
the appropriate master connection. %d masters to choose from. Something is wrong", \
zend_llist_count(l));
--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic