summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2017-04-04Ensure that subcall_sync use subcallJosé Bollo5-62/+63
The intent is to provide the asynchronous subcall as standard. This is needed for fixing subcall across connections (DBus or WebSocket). Change-Id: Ia046cfa4d0124bfa3ba7eb8e8f936eeafcf09875 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Avoid to count child threadsJosé Bollo1-7/+9
The count of allowed threads must be the real count of threads started. Change-Id: Iaefc9fa4368042d6db45ed3333f9591da027b2f0 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Improve debugging optionsJosé Bollo1-9/+1
Change-Id: I3550a4c2500b98efa985e678217e3d91bc8ca4c6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Add synchronous subcallsJosé Bollo10-41/+182
Synchronous subcalls are more easy for writing simple applications with sequential logic. Change-Id: I76a0231a64a6db8270014cd2a64284e1b0fc16ec Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Use SIGHUP instead of SIGKILLJosé Bollo1-4/+3
This doesn't enforces anymore the brutal termination. Change-Id: I62445c7cb3692354637906fb1ddda1787c8fb82a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Launch job at a earlier stepJosé Bollo9-48/+50
Change-Id: I3fcb96e4d748e38eacc4d413a451143dd9b4a10d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Definitive switch to internal's xreqJosé Bollo11-168/+16
This switch allows to work on a common base for the requests. Change-Id: I94e7fdda80c1966af399309334c41c7c8c8259dc Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Migrates subcalls to use xreqJosé Bollo3-125/+70
Change-Id: If865208bc0c207511d2b11e4cff617005ed01e56 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-04Introduce subcontext for subcallsJosé Bollo2-6/+29
Change-Id: I5460e9c502cee814c59a0ee60c2be001385e7b4a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-03Switch API D-Bus to xreqJosé Bollo1-110/+68
Change-Id: I16bfa2594f8de4babcc0d3cc1a62e7d0856d2479 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-03Switch API websocket to xreqJosé Bollo1-161/+53
Change-Id: I57600d8dc99bf37f207b126a0e3ab5731ad08ced Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-03Improve interface xreqJosé Bollo2-5/+41
Add missing function for further work Change-Id: I4e2b7a35b45ffb0edb1fd14b52500c9b00fab807 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-03Add notification message for added APIJosé Bollo1-0/+2
Change-Id: I797afeaa0758f2fef854a1ffaee398aff6c9041e Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-04-03Rework the jobsJosé Bollo5-304/+178
Enforce starting jobs with acquiring the calling thread. Removes invoke methods in favour of enter/leave synchronisation. Change-Id: I7086f7f53b919b43ddafd2355316abc0d3516f49 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-31Use xreq for servicesJosé Bollo3-59/+50
Change-Id: I05d0ddb36635c01b3d56ae52a08fbb68f3b3a6a9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-31Use xreq for websocketsJosé Bollo4-110/+36
Change-Id: Ia489f863e8be3384fbe8a240f6010f7d5916b72a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-31Factorize common code for handling requestsJosé Bollo16-122/+598
The common code for session handling is shared using struct afb_xreq. At the moment only hreq leverages the new feature. The objective is double: make the work of writing new internal requests more easy and prepare to check permissions. Change-Id: If3ca311d68c2d8c427d1125f31a2704b150c2c94 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-31Allow detection of session closureJosé Bollo1-2/+2
In some case it can be good to have a function called when the session closes. This is the case when a binding records an item in the context. With this modification the recorded item can be simply NULL. Change-Id: I5e23f00eb2a6e2639fdeea15f9dea79c7df9dfbb Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-30Start to implement the bindings V2José Bollo12-81/+515
More work has to be done for merging common code. Change-Id: I72b01901f978854843967c12bfcb3cc59cc10310 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-30Overall integration of job initialisationJosé Bollo4-25/+38
Move the job initialisation from main to jobs. Change-Id: I8f5b54adb62e60592884ff1e3fad9811b5934d47 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-30Fix concurrency issues on event managerJosé Bollo4-155/+140
Having only one event manager is not possible in multithreading due to the way that systemd has to manage timer events. We observed that timers were not armed when set in a thread because event was polling in an other thread. This patch provides more than one event manager and at most as many as the number of threads avalaible to start. Change-Id: Iaeab353b7bc79ce61361ab73c7b197a9e69a6109 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-30Refactor initialisation of the daemonJosé Bollo1-50/+66
This commit prepares a future job centrered main where 'sig_monitor_init', 'jobs_init', 'jobs_add_events', 'jobs_queue0' and 'jobs_add_me' will be merged in one single call provided as a feature of module jobs. Change-Id: I8ccb1bf1761c4fa1031e903bead863ff68e7df83 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-29Prepare migration to binding v2José Bollo5-119/+181
Change-Id: I48c1fdb5199c9fb0f001576ceed3ddcb50fc9066 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-29cosmeticJosé Bollo1-2/+11
Change-Id: I26e35f99a68557d005ee46dd4cd1c0fbd728bfd2 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-29Prepare move to bindings version 2José Bollo5-289/+366
Change-Id: I3105a5898d0703d1e57eff09f179b38742482842 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-29Add commentsJosé Bollo5-182/+464
Improves the comments of the module jobs Change-Id: Id99e9c6d6c9572d68ae9cca0f13e2498348de91d Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-28Refactor job to allow synchronous callsJosé Bollo4-140/+349
The family of methods "jobs_invoke" make synchronous job activation. It waits for the completion of the job while still dispatching it internally and providing the calling thread for processing any job queued. Change-Id: Id36a30789cc51245a7bbfca42f0122cf4ea623b2 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-28Fix bug in recycling jobsJosé Bollo4-8/+11
The bug was creating an infinite loop starving the system (or other possible horrific stuff). Also updated the test. Change-Id: Id71dd112d2ed4651ac8aa56d2c57b088d69b8655 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Make main thread used for common jobsJosé Bollo3-94/+229
This commit make the main thread behaving like any other threads. The main loop is shared across threads, the first one without job taking it. The main event loop now have the lowest priority. It is activated only when no job is queued. This has the good effect to not try to overfill the queue of jobs. Change-Id: I07cecc9d94a02134c63bc2a814db56e171ab719e Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Remove option readyfdJosé Bollo3-15/+0
This option is no more useful. Instead it is possible to use systemd notify feature. Change-Id: I8dd286242d3dc74238ca0908e83072367874d19e Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Speed up accesses to session's cookiesJosé Bollo1-13/+36
Minor improvement to speed up refactored contextes. Change-Id: I45c1c4b0cecec52d10c2b7c5cd8e738fd75b25d6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Replace session's value with sessions's cookiesJosé Bollo7-60/+11
This is a simplifaction with the benefits of only allocating needed memory and avoiding to create indexes on apis (path to dynanic?). Conversely it replaces a direct access with a linear search. Change-Id: Ibb130528ad8f23dfd6b420c228f51e181efb2664 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Implement dichotomic search of APIsJosé Bollo1-11/+49
This is a small improvement but it costs so few that it is welcome. Change-Id: I96db79b17ec811582c8e5d1d512afacece284016 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-27Simplify functions for callsJosé Bollo13-67/+108
For historical reasons, the call to apis was passing the length of the api and the length of the verb. The reason was to avoid a copy of strings. But the copy occured only for HTTP requests. Having this implementation is of small interest and compromise future changes. This patch simplify things. Change-Id: I8157724c6c721b6797cd0eab52b07e1b8d6eb5f8 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-22Refactor of threading and signal monitorJosé Bollo10-498/+626
The goal is to allow use of this facilities for things that are not 'afb_req'. Change-Id: I0d99c227934ed45136477bf6235bd1541d5f05cf Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-21Instanciate the environment variablesJosé Bollo1-50/+95
Because it could be of interest to transmit the port and the token in environment variables, provision is made here to instanciate environment variables before exec. Change-Id: I65cc8e052ca9e2831520a19d2da2a96ada7f672e Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-13Integration of socket activation for servicesJosé Bollo1-11/+22
The services provided using the option --ws-server can now be linked to socket activation of systemd. When afb-daemon is launched, the api to be provided by socket activation is declared by adding the option --ws-server=sd:APINAME Where APINAME is the name of the provided api. The binder looks to the prefix "sd:" to automatically use the "listen fd" of name APINAME for serving the api APINAME. In the socket activation unit the connection to this socket must be named using the directive FileDescriptorName as below: [socket] FileDescriptorName=APINAME ... Change-Id: I281e1a2b9fed3eac3bd0ee27b7f56df99df7bbd6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-13Beginning of integration as systemd serviceJosé Bollo4-2/+100
This allows to receive socket activation by names. Change-Id: I6896dec785e8d434da452ed2d1341016f6eadb60 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-13notify systemd of being startedJosé Bollo1-0/+2
Change-Id: I10251b0800ac44e59d2a17ebd202c9f55c5c9196 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-03-06Add comments about always setting INFER_EXTENSION.Sebastien Douheret2-0/+7
INFER_EXTENSION must always be set in order to provide right mimetypes for some files. For example mimetype for css files must be 'text/css' and not 'text/plain' as returned by libmagic. If mimetype is not correct, css files of HTML5 webapps will be not correctly interpreted resulting in a strange rendering in browser like Chrome. Change-Id: I7f0d9f97ede19308c87256f7850f5c51135827f3 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-02-27fix SEGFLT when unhendled requestJosé Bollo1-3/+5
Change-Id: I34c657972111db843d0d9d26a1732b21ac519c57 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-02-22Enable INFER_EXTENSION and add well-known mime types.Sebastien Douheret2-1/+6
Change-Id: I7c433eea63c01d2b0813a9cc84c12433839bf125 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-02-21Fix issue in initialisation of api by sessionsJosé Bollo1-2/+3
Change-Id: I72639196ce7462c34a2037cc825cf819add4a2fc Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-02-21fix issue for C++José Bollo1-1/+1
Change-Id: I14b5fb9a0f517d5a784cbbc43ca1401877d0f2fe Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-02-21fix mimetype by using libmagicJosé Bollo1-0/+1
Change-Id: I418b7f9323d4847dfef0f1f3f6dd90f6538b2ffb Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-02-16Update documentation of --roothttp option.Sebastien Douheret1-5/+5
By default when roothttp option is not set, no files are served but note that apis are still available. Change-Id: I461b6c94d4d16cf873c0f8fb2543576595ed24c1 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-02-16Ignore Visual Studio Code projectSebastien Douheret1-0/+1
Change-Id: Iecbef1a7887496deb849ab807ebf4de644e66343 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-02-15Fix html heading and hyperlink orderSebastien Douheret1-5/+5
Change-Id: I4f52c1c68fa357306faf6cd976a69e65de580fdb Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-01-12Improves documentation and directory managementJosé Bollo4-36/+99
Change-Id: I21c102f7439343476765c65011664feece2d2c18 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2017-01-11Add option --random-tokenJosé Bollo1-49/+76
Also fix a bug in use of getopt_long. Change-Id: Iffc90104665664c8e5a61fbee70f03f3cdb660cb Signed-off-by: José Bollo <jose.bollo@iot.bzh>