2 * Copyright (C) 2016, 2017 "IoT.bzh"
3 * Author José Bollo <jose.bollo@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
22 #include <afb/afb-req-itf.h>
24 #include "afb-thread.h"
26 #include "sig-monitor.h"
29 static void req_call(int signum, void *arg1, void *arg2, void *arg3)
31 struct afb_req req = { .itf = arg1, .closure = arg2 };
32 void (*callback)(struct afb_req) = arg3;
35 afb_req_fail_f(req, "aborted", "signal %s(%d) caught", strsignal(signum), signum);
41 void afb_thread_req_call(struct afb_req req, void (*callback)(struct afb_req req), int timeout, void *group)
48 sig_monitor3(timeout, req_call, (void*)req.itf, req.closure, callback);
51 rc = jobs_queue3(group, timeout, req_call, (void*)req.itf, req.closure, callback);
53 /* TODO: allows or not to proccess it directly as when no threading? (see above) */
54 ERROR("can't process job with threads: %m");
55 afb_req_fail_f(req, "cancelled", "not able to pipe a job for the task");