annotate src/os/unix/ngx_dlopen.c @ 6949:ff0c8e11edbc

Simplified and improved sendfile() code on Linux. The ngx_linux_sendfile() function is now used for both normal sendfile() and sendfile in threads. The ngx_linux_sendfile_thread() function was modified to use the same interface as ngx_linux_sendfile(), and is simply called from ngx_linux_sendfile() when threads are enabled. Special return code NGX_DONE is used to indicate that a thread task was posted and no further actions are needed. If number of bytes sent is less that what we were sending, we now always retry sending. This is needed for sendfile() in threads as the number of bytes we are sending might have been changed since the thread task was posted. And this is also needed for Linux 4.3+, as sendfile() might be interrupted at any time and provides no indication if it was interrupted or not (ticket #1174).
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 28 Mar 2017 18:15:39 +0300
parents 7142b04337d6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6380
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2 /*
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 * Copyright (C) Maxim Dounin
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4 * Copyright (C) Nginx, Inc.
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5 */
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8 #include <ngx_config.h>
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9 #include <ngx_core.h>
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
12 #if (NGX_HAVE_DLOPEN)
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14 char *
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15 ngx_dlerror(void)
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 {
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 char *err;
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 err = (char *) dlerror();
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21 if (err == NULL) {
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 return "";
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23 }
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25 return err;
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26 }
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27
7142b04337d6 Dynamic modules: dlopen() support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
28 #endif