From 56c1617f8e2f2f629600c09277aae1f3b9dcdb71 Mon Sep 17 00:00:00 2001 From: Jon Meredith Date: Mon, 8 Jun 2009 11:00:09 -0600 Subject: [PATCH] Converted truncate to use async_dbref. --- c_src/bdberl_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/c_src/bdberl_drv.c b/c_src/bdberl_drv.c index e00219a..c2985b4 100644 --- a/c_src/bdberl_drv.c +++ b/c_src/bdberl_drv.c @@ -796,11 +796,10 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd, // the underlying handle disappearing since we have a reference. if (dbref == -1 || has_dbref(d, dbref)) { - memcpy(d->work_buffer, inbuf, inbuf_sz); - // Mark the port as busy and then schedule the appropriate async operation d->async_op = cmd; d->async_pool = G_TPOOL_GENERAL; + d->async_dbref = dbref; bdberl_tpool_run(d->async_pool, &do_async_truncate, d, 0, &d->async_job); // Let caller know that the operation is in progress @@ -2301,10 +2300,9 @@ static void do_async_truncate(void* arg) PortData* d = (PortData*)arg; // Get the database reference and flags from the payload - int dbref = UNPACK_INT(d->work_buffer, 0); int rc = 0; - if (dbref == -1) + if (d->async_dbref == -1) { DBG("Truncating all open databases...\r\n"); @@ -2331,7 +2329,7 @@ static void do_async_truncate(void* arg) } else { - DB* db = G_DATABASES[dbref].db; + DB* db = G_DATABASES[d->async_dbref].db; DBG("Truncating dbref %i\r\n", dbref);