-
Notifications
You must be signed in to change notification settings - Fork 347
Manual pages for libunit. #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
.\" (C) 2023, NGINX, Inc. | ||
.\" | ||
.TH nxt_unit_ctx_alloc 3 (date) "NGINX Unit (unreleased)" | ||
.SH Name | ||
nxt_unit_ctx_alloc \- create context object for Unit app thread | ||
.SH Library | ||
NGINX Unit library | ||
.RI ( libunit ", " -lunit ) | ||
.SH Synopsis | ||
.nf | ||
.B #include <nxt_unit.h> | ||
.PP | ||
.B [[gnu::malloc(nxt_unit_done)]] | ||
.BI "nxt_unit_ctx_t *_Nullable nxt_unit_ctx_alloc(nxt_unit_ctx_t *" ctx , | ||
.BI " void *_Nullable " data ); | ||
.fi | ||
.SH Arguments | ||
.TP | ||
.I ctx | ||
Main context object for the application. | ||
It should have been created with | ||
.MR nxt_unit_init 3 . | ||
.TP | ||
.I data | ||
XXX | ||
.SH Description | ||
.MR nxt_unit_ctx_alloc 3 | ||
creates a context object that will be used for a worker thread. | ||
.PP | ||
The next step after creating a thread context object | ||
is running the application thread; | ||
for that, see | ||
.MR nxt_unit_run 3 . | ||
.PP | ||
The context object created by this function should be | ||
destroyed by passing it to | ||
.MR nxt_unit_done 3 . | ||
.SH Return value | ||
A pointer to a context object on success, | ||
or NULL on error. | ||
.SH Errors | ||
Errors will be reported in the Unit debug log. | ||
.IP \[bu] 3 | ||
.MR pthread_mutex_init 3 | ||
failed. | ||
.PD 0 | ||
.IP \[bu] | ||
.MR socketpair 2 | ||
failed. | ||
.IP \[bu] | ||
.MR setsockopt 2 | ||
failed. | ||
.IP \[bu] | ||
.MR memfd_create 2 | ||
failed. | ||
.IP \[bu] | ||
.MR shm_open 2 | ||
failed. | ||
.IP \[bu] | ||
.MR ftruncate 2 | ||
failed. | ||
.IP \[bu] | ||
.MR mmap 2 | ||
failed. | ||
.IP \[bu] | ||
.MR sendmsg 2 | ||
failed. | ||
.IP \[bu] | ||
.MR nxt_unit_malloc 3 | ||
failed. | ||
.IP \[bu] | ||
.I nxt_unit_init_t::callbacks.port_send | ||
failed. | ||
.IP \[bu] | ||
Internal hash table failure. | ||
.PD | ||
.SH Examples | ||
See | ||
.MR nxt_unit_init 3 | ||
for an example where this | ||
.IR worker () | ||
function is used. | ||
.PP | ||
.EX | ||
#include <pthread.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
\& | ||
#include <nxt_unit.h> | ||
\& | ||
void * | ||
worker(void *main_ctx) | ||
{ | ||
int rc; | ||
nxt_unit_ctx_t *ctx; | ||
\& | ||
ctx = nxt_unit_ctx_alloc(main_ctx, NULL); | ||
if (ctx == NULL) { | ||
pthread_exit(NULL); | ||
} | ||
\& | ||
nxt_unit_debug(ctx, "start worker"); | ||
rc = nxt_unit_run(ctx); | ||
nxt_unit_debug(ctx, "worker finished with %d code", rc); | ||
\& | ||
nxt_unit_done(ctx); | ||
\& | ||
pthread_exit((void *) (intptr_t) rc); | ||
} | ||
.EE | ||
.SH Copyright | ||
(C) 2017-2023, NGINX, Inc. | ||
.PP | ||
SPDX-License-Identifier: Apache-2.0 | ||
.SH See also | ||
.MR nxt_unit_done 3 , | ||
.MR nxt_unit_run 3 , | ||
.MR pthread_create 3 , | ||
.MR pthread_exit 3 , | ||
.MR unitd 8 | ||
.PP | ||
Website | ||
.UR https://unit.nginx.org | ||
.UE | ||
.PP | ||
Mailing list | ||
.UR https://mailman.nginx.org/mailman/listinfo/unit | ||
.UE | ||
.PP | ||
GitHub | ||
.UR https://github.com/nginx/unit | ||
.UE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
nxt_unit_ctx_alloc(3) Library Functions Manual nxt_unit_ctx_alloc(3) | ||
|
||
Name | ||
nxt_unit_ctx_alloc - create context object for Unit app thread | ||
|
||
Library | ||
NGINX Unit library (libunit, ‐lunit) | ||
|
||
Synopsis | ||
#include <nxt_unit.h> | ||
|
||
[[gnu::malloc(nxt_unit_done)]] | ||
nxt_unit_ctx_t *_Nullable nxt_unit_ctx_alloc(nxt_unit_ctx_t *ctx, | ||
void *_Nullable data); | ||
|
||
Arguments | ||
ctx Main context object for the application. It should have been | ||
created with nxt_unit_init(3). | ||
|
||
data XXX | ||
|
||
Description | ||
nxt_unit_ctx_alloc(3) creates a context object that will be used for a | ||
worker thread. | ||
|
||
The next step after creating a thread context object is running the ap‐ | ||
plication thread; for that, see nxt_unit_run(3). | ||
|
||
The context object created by this function should be destroyed by | ||
passing it to nxt_unit_done(3). | ||
|
||
Return value | ||
A pointer to a context object on success, or NULL on error. | ||
|
||
Errors | ||
Errors will be reported in the Unit debug log. | ||
|
||
• pthread_mutex_init(3) failed. | ||
• socketpair(2) failed. | ||
• setsockopt(2) failed. | ||
• memfd_create(2) failed. | ||
• shm_open(2) failed. | ||
• ftruncate(2) failed. | ||
• mmap(2) failed. | ||
• sendmsg(2) failed. | ||
• nxt_unit_malloc(3) failed. | ||
• nxt_unit_init_t::callbacks.port_send failed. | ||
• Internal hash table failure. | ||
|
||
Examples | ||
See nxt_unit_init(3) for an example where this worker() function is | ||
used. | ||
|
||
#include <pthread.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include <nxt_unit.h> | ||
|
||
void * | ||
worker(void *main_ctx) | ||
{ | ||
int rc; | ||
nxt_unit_ctx_t *ctx; | ||
|
||
ctx = nxt_unit_ctx_alloc(main_ctx, NULL); | ||
if (ctx == NULL) { | ||
pthread_exit(NULL); | ||
} | ||
|
||
nxt_unit_debug(ctx, "start worker"); | ||
rc = nxt_unit_run(ctx); | ||
nxt_unit_debug(ctx, "worker finished with %d code", rc); | ||
|
||
nxt_unit_done(ctx); | ||
|
||
pthread_exit((void *) (intptr_t) rc); | ||
} | ||
|
||
Copyright | ||
(C) 2017‐2023, NGINX, Inc. | ||
|
||
SPDX‐License‐Identifier: Apache‐2.0 | ||
|
||
See also | ||
nxt_unit_done(3), nxt_unit_run(3), pthread_create(3), pthread_exit(3), | ||
unitd(8) | ||
|
||
Website ⟨https://unit.nginx.org⟩ | ||
|
||
Mailing list ⟨https://mailman.nginx.org/mailman/listinfo/unit⟩ | ||
|
||
GitHub ⟨https://github.com/nginx/unit⟩ | ||
|
||
NGINX Unit (unreleased) (date) nxt_unit_ctx_alloc(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
[4mnxt_unit_ctx_alloc[24m(3) Library Functions Manual [4mnxt_unit_ctx_alloc[24m(3) | ||
|
||
[1mName[0m | ||
nxt_unit_ctx_alloc - create context object for Unit app thread | ||
|
||
[1mLibrary[0m | ||
NGINX Unit library ([4mlibunit[24m, [4m‐lunit[24m) | ||
|
||
[1mSynopsis[0m | ||
[1m#include <nxt_unit.h>[0m | ||
|
||
[1m[[gnu::malloc(nxt_unit_done)]][0m | ||
[1mnxt_unit_ctx_t *_Nullable nxt_unit_ctx_alloc(nxt_unit_ctx_t *[4m[22mctx[24m[1m,[0m | ||
[1mvoid *_Nullable [4m[22mdata[24m[1m);[0m | ||
|
||
[1mArguments[0m | ||
[4mctx[24m Main context object for the application. It should have been | ||
created with [4mnxt_unit_init[24m(3). | ||
|
||
[4mdata[24m XXX | ||
|
||
[1mDescription[0m | ||
[4mnxt_unit_ctx_alloc[24m(3) creates a context object that will be used for a | ||
worker thread. | ||
|
||
The next step after creating a thread context object is running the ap‐ | ||
plication thread; for that, see [4mnxt_unit_run[24m(3). | ||
|
||
The context object created by this function should be destroyed by | ||
passing it to [4mnxt_unit_done[24m(3). | ||
|
||
[1mReturn value[0m | ||
A pointer to a context object on success, or NULL on error. | ||
|
||
[1mErrors[0m | ||
Errors will be reported in the Unit debug log. | ||
|
||
• [4mpthread_mutex_init[24m(3) failed. | ||
• [4msocketpair[24m(2) failed. | ||
• [4msetsockopt[24m(2) failed. | ||
• [4mmemfd_create[24m(2) failed. | ||
• [4mshm_open[24m(2) failed. | ||
• [4mftruncate[24m(2) failed. | ||
• [4mmmap[24m(2) failed. | ||
• [4msendmsg[24m(2) failed. | ||
• [4mnxt_unit_malloc[24m(3) failed. | ||
• [4mnxt_unit_init_t::callbacks.port_send[24m failed. | ||
• Internal hash table failure. | ||
|
||
[1mExamples[0m | ||
See [4mnxt_unit_init[24m(3) for an example where this [4mworker[24m() function is | ||
used. | ||
|
||
#include <pthread.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include <nxt_unit.h> | ||
|
||
void * | ||
worker(void *main_ctx) | ||
{ | ||
int rc; | ||
nxt_unit_ctx_t *ctx; | ||
|
||
ctx = nxt_unit_ctx_alloc(main_ctx, NULL); | ||
if (ctx == NULL) { | ||
pthread_exit(NULL); | ||
} | ||
|
||
nxt_unit_debug(ctx, "start worker"); | ||
rc = nxt_unit_run(ctx); | ||
nxt_unit_debug(ctx, "worker finished with %d code", rc); | ||
|
||
nxt_unit_done(ctx); | ||
|
||
pthread_exit((void *) (intptr_t) rc); | ||
} | ||
|
||
[1mCopyright[0m | ||
(C) 2017‐2023, NGINX, Inc. | ||
|
||
SPDX‐License‐Identifier: Apache‐2.0 | ||
|
||
[1mSee also[0m | ||
[4mnxt_unit_done[24m(3), [4mnxt_unit_run[24m(3), [4mpthread_create[24m(3), [4mpthread_exit[24m(3), | ||
[4munitd[24m(8) | ||
|
||
Website ⟨https://unit.nginx.org⟩ | ||
|
||
Mailing list ⟨https://mailman.nginx.org/mailman/listinfo/unit⟩ | ||
|
||
GitHub ⟨https://github.com/nginx/unit⟩ | ||
|
||
NGINX Unit (unreleased) (date) [4mnxt_unit_ctx_alloc[24m(3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.\" (C) 2023, NGINX, Inc. | ||
.\" | ||
.TH nxt_unit_done 3 (date) "NGINX Unit (unreleased)" | ||
.SH Name | ||
nxt_unit_done \- destroy context object in Unit app | ||
.SH Library | ||
NGINX Unit library | ||
.RI ( libunit ", " -lunit ) | ||
.SH Synopsis | ||
.nf | ||
.B #include <nxt_unit.h> | ||
.PP | ||
.BI "void nxt_unit_done(nxt_unit_ctx_t *" ctx ); | ||
.fi | ||
.SH Arguments | ||
.TP | ||
.I ctx | ||
Context object to be destroyed. | ||
It should have been created with | ||
.MR nxt_unit_init 3 | ||
or | ||
.MR nxt_unit_ctx_alloc 3 . | ||
.SH Description | ||
.MR nxt_unit_done 3 | ||
destroys a context object in a Unit application. | ||
.SH Return value | ||
None. | ||
.SH Errors | ||
None. | ||
.SH Examples | ||
See | ||
.MR nxt_unit_init 3 | ||
and | ||
.MR nxt_unit_ctx_alloc 3 . | ||
.SH Copyright | ||
(C) 2017-2023, NGINX, Inc. | ||
.PP | ||
SPDX-License-Identifier: Apache-2.0 | ||
.SH See also | ||
.MR nxt_unit_ctx_alloc 3 , | ||
.MR nxt_unit_init 3 , | ||
.MR unitd 8 | ||
.PP | ||
Website | ||
.UR https://unit.nginx.org | ||
.UE | ||
.PP | ||
Mailing list | ||
.UR https://mailman.nginx.org/mailman/listinfo/unit | ||
.UE | ||
.PP | ||
GitHub | ||
.UR https://github.com/nginx/unit | ||
.UE |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth noting that this must happen before the parent context is destroyed (at least as far as I understand from looking at the code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, worth mentioning.