Permalink
Browse files

[cleanup] stdlib: Remove locks from Mongo.db.

  • Loading branch information...
nrs135 committed Nov 10, 2011
1 parent 815c917 commit 6e63fdead4fde394580b226d452b8707cd47eec3
Showing with 1 addition and 13 deletions.
  1. +1 −13 stdlib/apis/mongo/mongo.opa
@@ -62,8 +62,6 @@ type Mongo.mongo_host = (string, int)
type Mongo.db = {
conn : Mutable.t(option(Socket.connection));
conncell : Cell.cell(Mongo.sr,Mongo.srr);
- lock : Mutable.t(bool);
- mblock : Mutable.t(bool);
primary : Mutable.t(option(Mongo.mongo_host));
bufsize : int;
log : bool;
@@ -509,19 +507,14 @@ MongoDriver = {{
send_no_reply_(m,mbuf,name,reply_expected): bool =
match m.conn.get() with
| {some=conn} ->
- do if m.lock.get() then ML.warning("Mongo.send({name})","Double write on connection",void)
- do m.lock.set(true)
(str, len) = export_(mbuf)
s = String.substring(0,len,str)
do if m.log then ML.debug("Mongo.send({name})","\n{string_of_message(s)}",void)
(match Socket.write_len_with_err_cont(conn,m.comms_timeout,s,len) with
- //(match write(m,s,len) with
| {success=cnt} ->
- do m.lock.set(false)
do if not(reply_expected) then free_(mbuf) else void
(cnt==len)
| {failure=_} ->
- do m.lock.set(false)
// Awkward, we may be in the first part of a send_with_reply or in a simple send_no_reply.
if reply_expected
then false
@@ -546,18 +539,13 @@ MongoDriver = {{
if send_no_reply_(m,mbuf,name,true)
then
mailbox = new_mailbox_(m.bufsize)
- do if m.lock.get() then ML.warning("Mongo.receive({name})","Double read on connection",void)
- do m.mblock.set(true)
(match read_mongo_(conn,m.comms_timeout,mailbox) with
- //(match read(m,mailbox) with
| {success=reply} ->
- do m.mblock.set(false)
do reset_mailbox_(mailbox)
do free_(mbuf)
do if m.log then ML.debug("Mongo.receive({name})","\n{string_of_message_reply(reply)}",void)
{some=reply}
| {~failure} ->
- do m.mblock.set(false)
do if m.log then ML.info("send_with_reply","failure={failure}",void)
do reset_mailbox_(mailbox)
myreconnect())
@@ -615,7 +603,7 @@ MongoDriver = {{
conn = Mutable.make({none})
{ ~conn;
conncell=(Cell.make(conn, sr):Cell.cell(Mongo.sr,Mongo.srr));
- lock=Mutable.make(false); mblock=Mutable.make(false); ~bufsize; ~log;
+ ~bufsize; ~log;
seeds=[]; hosts=Mutable.make([]); name="";
primary=Mutable.make({none}); reconnect=Mutable.make({none});
reconnect_wait=2000; max_attempts=30; comms_timeout=3600000;

0 comments on commit 6e63fde

Please sign in to comment.