Jacob Perkins avatar Jacob Perkins committed 2259a12

emongo_server:send does gen_server:cast

Comments (0)

Files changed (1)


 	gen_server:start_link(?MODULE, [PoolId, Host, Port], []).
 send(Pid, ReqID, Packet) ->
-	case gen_server:call(Pid, {send, ReqID, Packet}) of
-		{ok, Result} -> Result;
+	case gen_server:cast(Pid, {send, ReqID, Packet}) of
+		ok -> ok;
 		{error, Reason} -> exit(Reason)
 	Socket = open_socket(Host, Port),
 	{ok, #state{pool_id=PoolId, socket=Socket, requests=[], leftover = <<>>}}.
-handle_call({send, _, Packet}, _From, State) ->
-	% TODO: make this a cast
-	gen_tcp:send(State#state.socket, Packet),
-	{reply, ok, State};
 handle_call({send_recv, ReqID, Packet}, From, State) ->
 	gen_tcp:send(State#state.socket, Packet),
 	Request = #request{req_id=ReqID, requestor=From},
 	State1 = State#state{requests=[{ReqID, Request} | State#state.requests]},
 	{noreply, State1}.
-handle_cast(_, State) -> {noreply, State}.
+handle_cast({send, _, Packet}, State) ->
+	gen_tcp:send(State#state.socket, Packet),
+	{noreply, State}.
 handle_info({tcp, _Socket, Data}, State) ->
 	Leftover = <<(State#state.leftover)/binary, Data/binary>>,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.