Browse code

db_cassandra: return 0 in case of successful operations

- following better DB APIv1 convention and avoiding inappropriate
failure detection in some modules
- reported and patch by Jay Binks

(cherry picked from commit f475f2886f37b2a9cb5782ef1f5b9a6e94cee4dc)

Daniel-Constantin Mierla authored on 06/03/2014 08:49:51
Showing 1 changed files
... ...
@@ -570,7 +570,7 @@ ColumnVecPtr cassa_translate_query(const db1_con_t* _h, const db_key_t* _k,
570 570
 			}
571 571
 			dbcassa_reconnect(CON_CASSA(_h));
572 572
 		} while(cassa_auto_reconnect && retr++ < cassa_retries);
573
-
573
+		LM_ERR("Failed to connect, retries exceeded.\n");
574 574
 	} catch (const oac::InvalidRequestException ir) {
575 575
 		LM_ERR("Failed Invalid query request: %s\n", ir.why.c_str());
576 576
 	} catch (const at::TException &tx) {
... ...
@@ -1062,7 +1062,7 @@ int db_cassa_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op,
1062 1062
 done:
1063 1063
 	*_r = db_res;
1064 1064
 	LM_DBG("Exited with success\n");
1065
-	return 1;
1065
+	return 0;
1066 1066
 
1067 1067
 error:
1068 1068
 	if(db_res)
... ...
@@ -1208,14 +1208,14 @@ int db_cassa_modify(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
1208 1208
 			if(CON_CASSA(_h)->con) {
1209 1209
 				try{
1210 1210
 					CON_CASSA(_h)->con->batch_mutate(CFMap, oac::ConsistencyLevel::ONE);
1211
-					return 1;
1211
+					return 0;
1212 1212
 				}  catch (const att::TTransportException &tx) {
1213 1213
 					LM_ERR("Failed to query: %s\n", tx.what());
1214 1214
 				}
1215 1215
 			}
1216 1216
 			dbcassa_reconnect(CON_CASSA(_h));
1217 1217
 		} while (cassa_auto_reconnect && retr++ < cassa_retries);
1218
-
1218
+		LM_ERR("Failed to connect, retries exceeded.\n");
1219 1219
 	} catch (const oac::InvalidRequestException ir) {
1220 1220
 		LM_ERR("Failed Invalid query request: %s\n", ir.why.c_str());
1221 1221
 	} catch (const at::TException &tx) {
... ...
@@ -1336,13 +1336,14 @@ int db_cassa_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
1336 1336
 				if(CON_CASSA(_h)->con) {
1337 1337
 					try {
1338 1338
 						cassa_client->remove(row_key, cp, (int64_t)time(0), oac::ConsistencyLevel::ONE);
1339
-						return 1;
1339
+						return 0;
1340 1340
 					} catch  (const att::TTransportException &tx) {
1341 1341
 							LM_ERR("Failed to query: %s\n", tx.what());
1342 1342
 					}
1343 1343
 				}
1344 1344
 				dbcassa_reconnect(CON_CASSA(_h));
1345 1345
 			} while(cassa_auto_reconnect && retr++ < cassa_retries);
1346
+			LM_ERR("Failed to connect, retries exceeded.\n");
1346 1347
 		} else {
1347 1348
 
1348 1349
 			if(!seckey_len) {
... ...
@@ -1395,7 +1396,7 @@ int db_cassa_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
1395 1396
 				if(CON_CASSA(_h)->con) {
1396 1397
 					try {
1397 1398
 						cassa_client->batch_mutate(CFMap, oac::ConsistencyLevel::ONE);
1398
-						return 1;
1399
+						return 0;
1399 1400
 					} catch  (const att::TTransportException &tx) {
1400 1401
 							LM_ERR("Failed to query: %s\n", tx.what());
1401 1402
 					}
... ...
@@ -1403,7 +1404,7 @@ int db_cassa_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o,
1403 1404
 				dbcassa_reconnect(CON_CASSA(_h));
1404 1405
 			} while(cassa_auto_reconnect && retr++ < cassa_retries);
1405 1406
 		}
1406
-		return 1;
1407
+		LM_ERR("Failed to connect, retries exceeded.\n");
1407 1408
 	} catch (const oac::InvalidRequestException ir) {
1408 1409
 		LM_ERR("Invalid query: %s\n", ir.why.c_str());
1409 1410
 	} catch (const at::TException &tx) {