anchor.diff:  wakeup_worker(Job) ->
       wakeup ! {self(),Job}.
       
  -find_worker(Job) ->
  -    Workers = dbq(qlc:q([W#worker.sock || W <- mnesia:table(worker),
  -                                          W#worker.state =:= ready,
  -                                          F <- mnesia:table(function),
  -                                          W#worker.sock =:= F#function.sock,
  -                                          F#function.name =:= Job#work.name ])),
  -    case Workers of
  -        [] -> null;
  -        Workers -> hd(Workers)
  -    end.
  -
  -find_work(Worker) ->
  -    Now = now(),
  -    Jobs = dbq(qlc:keysort(2,
  -                           qlc:q([J || J <- mnesia:table(work),
  -                                       J#work.assigned =:= null,
  -                                       J#work.schedule =< Now,
  -                                       F <- mnesia:table(function),
  -                                       F#function.sock =:= Worker,
  -                                       J#work.name =:= F#function.name
  -                                 ]))),
  -    case Jobs of
  -        [] -> null;
  -        Jobs -> hd(Jobs)
  -    end.
  -
   findDelimiters(Bin,Delim,Lim) ->
       findDelimiters(Bin,Delim,Lim,1,[]).
   
  
positive.code:             handle(Socket);
          {error, closed} ->
              %fprof:trace(stop),
              mnesia:transaction(
                fun() -> 
                        dbq(qlc:q([mnesia:delete({function, X#function.sock}) || X <- mnesia:table(function), X#function.sock =:= Socket])),
                        dbq(qlc:q([mnesia:delete({worker, X#worker.sock})     || X <- mnesia:table(worker),   X#worker.sock =:= Socket])),
                        
                        %% if it died while work was still running on it, then update the queue so it can be issued out again    
                        Jobs = dbq(qlc:q([X#work{assigned=null} || X <- mnesia:table(work),   X#work.assigned =:= Socket])),
                        [mnesia:write(X) || X <- Jobs],
                        %% if jobs found, then kick some other worker to handle the workload
                        %% that this one just abandoned
                        [wakeup_worker(Job) || Job <- Jobs]
                end
               ),
              ok;
          UnhandledMessage ->
              ?DEBUG("unhandled message: ~p~n", [UnhandledMessage]),
              handle(Socket)
  
negative.code:        tohex(E1),tohex(E2),tohex(E3),tohex(E4),tohex(E5),tohex(E6),
         tohex(E7),tohex(E8),tohex(E9),tohex(E10),tohex(E11),tohex(E12)
        ]).
  