Skip to content

Commit

Permalink
Merge pull request #1688 from 2600hz/KAZOO-4594
Browse files Browse the repository at this point in the history
KAZOO-4594: catch possible crashes in fax_workers
  • Loading branch information
lazedo committed Mar 11, 2016
2 parents b575251 + c22ae93 commit 6ab70e5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions applications/fax/src/fax_worker.erl
Expand Up @@ -352,15 +352,25 @@ handle_cast('prepare_job', #state{job_id=JobId
end;
handle_cast('count_pages', #state{file=File
,job=JObj
,pool=Pid
}=State) ->
{NumberOfPages, FileSize} = get_sizes(File),
Values = [{<<"pvt_pages">>, NumberOfPages}
,{<<"pvt_size">>, FileSize}
],
gen_server:cast(self(), 'send'),
{'noreply',State#state{job=wh_json:set_values(Values, JObj)
,pages=NumberOfPages
}};
try get_sizes(File) of
{NumberOfPages, FileSize} ->
Values = [{<<"pvt_pages">>, NumberOfPages}
,{<<"pvt_size">>, FileSize}
],
gen_server:cast(self(), 'send'),
{'noreply',State#state{job=wh_json:set_values(Values, JObj)
,pages=NumberOfPages
}}
catch
_Type:Exception ->
lager:debug("caught ~p: ~p", [_Type, Exception]),
send_error_status(State, Exception),
release_failed_job('bad_file', Exception, JObj),
gen_server:cast(Pid, {'job_complete', self()}),
{'noreply', reset(State)}
end;
handle_cast('send', #state{job_id=JobId
,job=JObj
,queue_name=Q
Expand Down

0 comments on commit 6ab70e5

Please sign in to comment.