gpointer ssl_delete_thread (gpointer _conn) // here, we pass the connection object { mongo_sync_connection *conn = (mongo_sync_connection*) _conn; static int delete_count = 0; delete_count++; bson *test_doc = bson_new (); gchar *test_string = g_strdup_printf ("%s:%d", "ssl_insert_thread", delete_count); bson_append_string (test_doc, test_string, "ok", -1); bson_finish (test_doc); ok (mongo_sync_cmd_delete (conn, config.ns, 0, test_doc), "mongo_sync_cmd_delete works in a multithreaded scenario"); bson_free (test_doc); g_free (test_string); return NULL; }
static void delete_old (mongo_sync_connection *conn) { bson *b; b = bson_build (BSON_TYPE_TIMESTAMP, "processed", 1294860709000, BSON_TYPE_NONE); bson_finish (b); //TODO How to delete all records? if (!mongo_sync_cmd_delete(conn, "blahblah.plurals", 0, b)) { fprintf (stderr, "Error creating index: %s\n", strerror(errno)); exit (1); bson_free (b); } }
NEOERR* mmg_delete(mmg_conn *db, char *dsn, int flags, char *sel) { bson *doc; MCS_NOT_NULLC(db, dsn, sel); mtc_noise("delete %s %s", dsn, sel); doc = mbson_new_from_string(sel, true); if (!doc) return nerr_raise(NERR_ASSERT, "build doc: %s: %s", sel, strerror(errno)); if (!mongo_sync_cmd_delete(db->con, dsn, flags, doc)) return nerr_raise(NERR_DB, "sync_cmd_delete: %s", strerror(errno)); bson_free(doc); return STATUS_OK; }
void test_func_mongo_sync_ssl_insert_query (void) { mongo_sync_connection *conn = NULL; bson *test_doc = bson_new (); mongo_packet *p = NULL; //gchar *test_string = g_strdup_printf ("%s:%s:%d", __FILE__, __func__, __LINE__); gchar *test_string = g_strdup ("test_func_mongo_sync_ssl_insert_query"); bson_append_string (test_doc, test_string, "ok", -1); bson_finish (test_doc); conn = mongo_sync_ssl_connect (config.primary_host, config.primary_port, TRUE, config.ssl_settings); //conn = mongo_sync_connect (config.primary_host, config.primary_port, TRUE); mongo_sync_conn_set_auto_reconnect (conn, TRUE); ok (conn != NULL, "connection works without whitelists"); ok (mongo_sync_cmd_insert (conn, config.ns, test_doc, NULL) == TRUE, "inserting a document works via SSL"); p = mongo_sync_cmd_query (conn, config.ns, 0, 0, 1, test_doc, NULL); ok (p != NULL, "querying the recently inserted document works via SSL"); mongo_wire_packet_free (p); shutdown (conn->super.fd, SHUT_RDWR); sleep (3); ok (mongo_sync_cmd_delete (conn, config.ns, 0, test_doc) == TRUE, "automatic reconnection over SSL should work (at this time: attempting delete command)"); /* ok (mongo_sync_cmd_query (conn, config.ns, 0, 0, 1, test_doc, NULL) == NULL, "test document should not exist after delete"); */ mongo_sync_disconnect (conn); bson_free (test_doc); g_free (test_string); }