Skip to content

Commit

Permalink
Rebuilt code base, supervised worker (need tests), merged with drkrab
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlobaron committed Apr 15, 2012
1 parent 4ceecd3 commit f1ff6b8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
23 changes: 23 additions & 0 deletions include/riak_mongo_sock.hrl
@@ -0,0 +1,23 @@
%%
%% This file is part of riak_mongo
%%
%% Copyright (c) 2012 by Pavlo Baron (pb at pbit dot org)
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%

%% @author Pavlo Baron <pb at pbit dot org>
%% @doc Some reusable socket stuff
%% @copyright 2012 Pavlo Baron

-define(SOCK_OPTS, [binary, {active, once}, {packet, 0}, {reuseaddr, true}]).
32 changes: 32 additions & 0 deletions src/riak_mongo_sock.erl
@@ -0,0 +1,32 @@
%%
%% This file is part of riak_mongo
%%
%% Copyright (c) 2012 by Pavlo Baron (pb at pbit dot org)
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%

%% @author Pavlo Baron <pb at pbit dot org>
%% @doc Some socket stuff
%% @copyright 2012 Pavlo Baron

-module(riak_mongo_sock).

-export([change_control/3, give_control/2]).

change_control(Sock, OldOwner, NewOwner) ->
OldOwner ! {controlling_process, Sock, NewOwner}.

give_control(Sock, NewOwner) ->
gen_tcp:controlling_process(Sock, NewOwner),
NewOwner ! {control, Sock}.

0 comments on commit f1ff6b8

Please sign in to comment.