private static void HandleCancelQuery(WvDbus conn, WvDbusMsg msg) { log.print(WvLog.L.Debug4, "Received CancelQuery request\n"); //FIXME: Should I be in yet another thread? Action perform = null; if (msg.signature != "u" && msg.signature != "s") { //accept 's' signatures for Perl DBus, which is stupid and can't //send me 'u' parameters, even though the api accepts them. log.print(WvLog.L.Debug4, "CancelQuery: bad signature {0}\n", msg.signature); perform = () => { conn.send(msg.err_reply( "org.freedesktop.DBus.Error.UnknownMethod", "No overload of {0} has signature '{1}'", "CancelQuery", msg.signature)); }; } else { var it = msg.iter(); uint tokill; if (msg.signature == "s") { log.print(WvLog.L.Debug4, "CancelQuery: converting arg from string\n"); string temps = it.pop(); tokill = Convert.ToUInt32(temps); } else tokill = it.pop(); log.print(WvLog.L.Debug4, "CancelQuery: try killing msg id {0}\n", tokill); lock (action_mutex) { if (curaction != null && curaction.conn == conn && curaction.src.serial == tokill) { log.print(WvLog.L.Debug4, "CancelQuery: killing current action!\n"); WvSqlRows_IDataReader.Cancel(); curaction = null; } else { log.print(WvLog.L.Debug4, "CancelQuery: traversing action queue...\n"); //Traverse the action queue, killing stuff foreach (VxActionTriple t in action_queue) if (t.conn == conn && t.src.serial == tokill) { log.print(WvLog.L.Debug4, "CancelQuery: found culprit, killing.\n"); //action_queue.Remove(t); //FIXME: What message should we really put here? t.action = () => { conn.send(t.src.err_reply("vx.db.sqlerror", "This message got canceled")); }; break; } } } //Pointless return to make Perl happy. perform = () => { WvDbusWriter writer = new WvDbusWriter(); writer.Write("Cancel"); conn.send(msg.reply("s").write(writer)); }; log.print(WvLog.L.Debug4, "CancelQuery: complete\n"); } //FIXME: It's not clear whether for just add operations, in conjuction //with RemoveAt(0) going on in the otherthread, we need a mutex. action_queue.Add(new VxActionTriple(conn, msg, perform)); }
static bool WvDbusMsgReady(WvDbus conn, WvDbusMsg msg) { // FIXME: This should really queue things to be run from the thread // pool and then the response would be sent back through the action // queue log.print(WvLog.L.Debug4, "WvDbusMsgReady\n"); switch (msg.type) { case Wv.Dbus.MType.MethodCall: if (msg.ifc == "vx.db") { if (msg.path == "/db" && msg.method == "CancelQuery") HandleCancelQuery(conn, msg); else //not 'CancelQuery' { //FIXME: It's not clear whether for just add operations, //in conjuction with RemoveAt(0) going on in the other //thread, we need a mutex. action_queue.Add(new VxActionTriple(conn, msg, () => { WvDbusMsg reply; if (msgrouter.route(conn, msg, out reply)) { if (reply == null) { // FIXME: Do something if this happens, maybe? log.print("Empty reply from RouteWvDbusMsg\n"); } else { // XXX: Should this be done further down rather // than passing the reply out here? conn.send(reply); } } })); } return true; } return false; default: log.print(WvLog.L.Warning, "Unexpected DBus message received: #{0} {1}->{2} {3}:{4}.{5}\n", msg.serial, msg.sender, msg.dest, msg.path, msg.ifc, msg.method); return false; } }