@@ -154,16 +154,6 @@ PS_OPEN_FUNC(memcached)
154
154
status = memcached_server_push (memc_sess -> memc_sess , servers );
155
155
memcached_server_list_free (servers );
156
156
157
- if (MEMC_G (sess_prefix ) && MEMC_G (sess_prefix )[0 ] != 0 && memcached_callback_set (memc_sess -> memc_sess , MEMCACHED_CALLBACK_PREFIX_KEY , MEMC_G (sess_prefix )) != MEMCACHED_SUCCESS ) {
158
- PS_SET_MOD_DATA (NULL );
159
- if (plist_key ) {
160
- efree (plist_key );
161
- }
162
- memcached_free (memc_sess -> memc_sess );
163
- php_error_docref (NULL TSRMLS_CC , E_WARNING , "bad memcached key prefix in memcached.sess_prefix" );
164
- return FAILURE ;
165
- }
166
-
167
157
if (status == MEMCACHED_SUCCESS ) {
168
158
goto success ;
169
159
}
@@ -211,6 +201,13 @@ PS_OPEN_FUNC(memcached)
211
201
return FAILURE ;
212
202
}
213
203
}
204
+
205
+ if (MEMC_G (sess_prefix ) && MEMC_G (sess_prefix )[0 ] != 0 ) {
206
+ if (memcached_callback_set (memc_sess -> memc_sess , MEMCACHED_CALLBACK_PREFIX_KEY , MEMC_G (sess_prefix )) != MEMCACHED_SUCCESS ) {
207
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "bad memcached key prefix in memcached.sess_prefix" );
208
+ return FAILURE ;
209
+ }
210
+ }
214
211
#ifdef HAVE_MEMCACHED_SASL
215
212
if (MEMC_G (use_sasl )) {
216
213
/*
@@ -331,7 +328,11 @@ PS_READ_FUNC(memcached)
331
328
* vallen = payload_len ;
332
329
free (payload );
333
330
return SUCCESS ;
331
+ } else if (status == MEMCACHED_NOTFOUND ) {
332
+ /* this is okey, session may not be in memcached yet */
333
+ return FAILURE ;
334
334
} else {
335
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "error getting session from memcached: %s" , memcached_last_error_message (memc_sess -> memc_sess ));
335
336
return FAILURE ;
336
337
}
337
338
}
@@ -371,6 +372,7 @@ PS_WRITE_FUNC(memcached)
371
372
if (status == MEMCACHED_SUCCESS ) {
372
373
return SUCCESS ;
373
374
} else {
375
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "error saving session to memcached: %s" , memcached_last_error_message (memc_sess -> memc_sess ));
374
376
write_try_attempts -- ;
375
377
}
376
378
} while (write_try_attempts > 0 );
0 commit comments