当前位置:首页>Linux>linux系统编程(一):pthread常用函数

linux系统编程(一):pthread常用函数

  • 2026-06-29 10:23:04
linux系统编程(一):pthread常用函数

Linux pthread 常用函数实战 —— 从 create 到 TLS

一行 pthread_create 起线程很简单,但要安全地停下、等到它退出、回收资源、还能传数据回来 —— 一套 pthread API 才够用。这篇把最常用的 14 个函数串起来,每个配最小可运行的 demo。


0. 一个钩子例子

把 1 ~ 10 亿求和,单线程跑约 2 秒。开 4 个线程并行算,每个负责 1/4,理论上能压到 0.5 秒。

主线程  ├─ worker 1:1 ~ 2.5 亿  ├─ worker 2:2.5 亿 ~ 5 亿  ├─ worker 3:5 亿 ~ 7.5 亿  └─ worker 4:7.5 亿 ~ 10 亿主线程等所有 worker 完成 → 把 4 个结果加起来

这一个场景就用到:

  • pthread_create
     起线程
  • pthread_join
     等结果
  • pthread_exit
     / return 带返回值
  • pthread_self
     调试时区分线程

下面一个一个看。


1. 线程生命周期:create / join / detach / exit

1.1 pthread_create —— 起线程

intpthread_create(pthread_t *thread,                   const pthread_attr_t *attr,                   void *(*start_routine)(void *),                   void *arg);
参数
含义
thread
输出:新线程的 tid 写到这里
attr
属性(栈大小、是否 detached 等),传 NULL 用默认
start_routine
入口函数,签名固定 void *(void *)
arg
传给入口函数的参数

最小例子:

#include<pthread.h>#include<stdio.h>void *worker(void *arg){    int id = *(int *)arg;    printf("worker %d running\n", id);    return NULL;}intmain(void){    pthread_t tid;    int id = 42;    pthread_create(&tid, NULL, worker, &id);    pthread_join(tid, NULL);    return 0;}

⚠️ arg 的生命周期:上面这个例子主线程 pthread_join 阻塞着,所以 id 这个栈变量是活的。如果改成 pthread_detach 不等就 return,id 已经被回收,worker 读到的就是垃圾。

1.2 pthread_exit —— 主动退出 + 带返回值

voidpthread_exit(void *retval);

retval 会被 pthread_join 拿到。直接 return 等价于 pthread_exit

void *worker(void *arg){    long sum = 0;    for (int i = 1; i <= 1000000; i++) sum += i;    return (void *)sum;        // 等价于 pthread_exit((void *)sum)}

1.3 pthread_join —— 阻塞等退出 + 拿返回值 + 回收资源

intpthread_join(pthread_t thread, void **retval);

阻塞当前线程,等 thread 退出,把它的返回值写到 retval

⚠️ 不 join 也不 detach = 线程退出后资源永远不回收(“僵尸线程”),是常见的资源泄漏原因。

把开头那个并行求和例子完整写出来:

#include<pthread.h>#include<stdio.h>#define N 4#define TOTAL 1000000000Ltypedef struct {    long start, end;range_t;void *sum_range(void *arg){    range_t *r = arg;    long s = 0;    for (long i = r->start; i <= r->end; i++) s += i;    return (void *)s;}intmain(void){    pthread_t tids[N];    range_t ranges[N];    long step = TOTAL / N;    long total = 0;    for (int i = 0; i < N; i++) {        ranges[i].start = i * step + 1;        ranges[i].end   = (i + 1) * step;        pthread_create(&tids[i], NULL, sum_range, &ranges[i]);    }    for (int i = 0; i < N; i++) {        void *ret;        pthread_join(tids[i], &ret);    // 等退出 + 拿返回值        total += (long)ret;    }    printf("sum = %ld\n", total);    return 0;}

1.4 pthread_detach —— “我不打算等了”

intpthread_detach(pthread_t thread);

线程被分离后:

  • 不需要 join
  • 退出时资源自动回收
  • 不能再 join 了(再 join 会返回错误)

适用场景:fire-and-forget 的后台任务,比如日志写入、心跳上报、网络服务的 per-connection handler。

void *background_log(void *arg){    while (1) {        write_log_to_disk();        sleep(1);    }    return NULL;}intmain(void){    pthread_t tid;    pthread_create(&tid, NULL, background_log, NULL);    pthread_detach(tid);    // 不打算等了    do_main_work();    return 0;}

也可以在创建时直接设 PTHREAD_CREATE_DETACHED 属性:

pthread_attr_t attr;pthread_attr_init(&attr);pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);pthread_create(&tid, &attr, ...);pthread_attr_destroy(&attr);

2. 取消机制:cancel / cleanup / state / type

2.1 pthread_cancel —— 请求其他线程退出

intpthread_cancel(pthread_t thread);

向目标线程发取消请求。注意:只是请求,不是强制退出。目标线程在到达"取消点"(cancellation point)时才真的退出。

常见的取消点:read / write / poll / sleep / pthread_cond_wait / pthread_join 等阻塞 syscall。完整列表见 man 7 pthreads

例子:可中断的下载

void *download_worker(void *arg){    while (more_data) {        int n = recv(sock, buf, sizeof(buf), 0);   // 取消点        write(file, buf, n);                        // 取消点    }    return NULL;}intmain(void){    pthread_t tid;    pthread_create(&tid, NULL, download_worker, NULL);    sleep(5);    pthread_cancel(tid);          // 5 秒后取消下载    pthread_join(tid, NULL);    return 0;}

2.2 pthread_cleanup_push / pop —— cancel 安全的资源释放

线程在阻塞点被 cancel 时,已经持有的资源(mutex、内存、文件、socket 等)需要自动释放。用 cleanup handler:

void cleanup_unlock(void *arg) {    pthread_mutex_unlock((pthread_mutex_t *)arg);}void *worker(void *arg) {    pthread_mutex_lock(&m);    pthread_cleanup_push(cleanup_unlock, &m);   // 注册 handler    pthread_cond_wait(&cv, &m);    // 取消点;如果被 cancel,handler 会被自动调    pthread_cleanup_pop(1);        // 1 = 执行 handler;0 = 仅注销    return NULL;}

⚠️ cleanup_push 和 cleanup_pop 必须配对在同一个作用域,因为它们底层是宏,依赖局部变量做记账。

2.3 pthread_setcancelstate / setcanceltype —— 控制何时响应

intpthread_setcancelstate(int state, int *oldstate);//   PTHREAD_CANCEL_ENABLE   - 默认//   PTHREAD_CANCEL_DISABLE  - 屏蔽 cancel(请求被挂起,state 改回 ENABLE 后才生效)intpthread_setcanceltype(int type, int *oldtype);//   PTHREAD_CANCEL_DEFERRED      - 默认,到 cancellation point 才取消//   PTHREAD_CANCEL_ASYNCHRONOUS  - 立即取消(很危险,几乎不用)

进入临界区前可以暂时禁用 cancel:

int oldstate;pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);do_critical_thing();pthread_setcancelstate(oldstate, NULL);

2.4 pthread_testcancel —— 显式检查

如果一段代码完全没有 cancellation point(比如纯 CPU 循环),又想响应 cancel,手动插入:

for (int i = 0; i < 1000000; i++) {    do_calc(i);    if (i % 1000 == 0)        pthread_testcancel();   // 显式检查}

3. 线程标识:self / setname_np

3.1 pthread_self —— 拿自己的 tid

pthread_tpthread_self(void);

调试 log 常用:

printf("[tid=%lu] processing\n", (unsigned long)pthread_self());

⚠️ pthread_t 在 glibc 上是 unsigned long,但 POSIX 标准没规定具体类型。跨平台代码要用 pthread_equal(t1, t2) 比较,不要直接用 ==

3.2 pthread_setname_np —— 设线程名(调试用)

intpthread_setname_np(pthread_t thread, constchar *name);

线程名最长 16 字节(含 \0)。设了之后 top -Hps -eLhtopgdb info threads 都能看到,调试很方便:

void *worker(void *arg) {    pthread_setname_np(pthread_self(), "downloader");    ...}

_np 后缀是 “non-portable”,但 Linux / BSD / macOS 都支持(macOS 上 pthread_setname_np 只接一个参数)。


4. 一次性初始化:pthread_once

intpthread_once(pthread_once_t *once_control, void (*init_routine)(void));

保证 init_routine 在多线程环境下只被执行一次,且其他线程会等第一次执行完。

经典场景:线程安全的单例 / 懒初始化。

#include<pthread.h>static pthread_once_t once = PTHREAD_ONCE_INIT;static config_t *g_config = NULL;staticvoidinit_config(void){    g_config = load_config_from_file();}config_t *get_config(void){    pthread_once(&once, init_config);    return g_config;}

不管多少个线程同时调 get_configinit_config 只会执行一次,其他线程被阻塞到第一次执行完。

比"双重检查锁定"(DCLP)写法更简洁,且不会出错。


5. 线程局部存储(TLS):key_create / setspecific / getspecific

intpthread_key_create(pthread_key_t *key, void (*destructor)(void *));intpthread_setspecific(pthread_key_t key, constvoid *value);void *pthread_getspecific(pthread_key_t key);

每个线程拥有自己独立的"key 对应的值"。经典例子:errno 就是 TLS 实现的(每个线程的 errno 互不影响)。

static pthread_once_t once = PTHREAD_ONCE_INIT;static pthread_key_t my_key;staticvoiddestructor(void *value){    free(value);}staticvoidinit_key(void){    pthread_key_create(&my_key, destructor);}char *get_thread_buffer(void){    pthread_once(&once, init_key);    char *buf = pthread_getspecific(my_key);    if (!buf) {        buf = malloc(1024);        pthread_setspecific(my_key, buf);    }    return buf;}

线程退出时 destructor 自动被调用,释放各自的 buf。

C11 还提供 _Thread_local 关键字(gcc 也支持 __thread),更简洁:

__thread char buf[1024];   // 每个线程独立一份

只是 __thread 不能动态分配 + 自动释放,复杂场景还是用 pthread_key_*


6. 线程生命周期一图流

线程从 pthread_create 进入 Running 状态后,有三条退出路径:

  1. 正常退出
    return 或 pthread_exit → Terminated
  2. 被取消
    pthread_cancel 触发 + 到达 cancellation point → 执行 cleanup handlers → Terminated
  3. 进程退出
    :所有线程一起死

Terminated 之后两条回收路径:

  • 被 join
    :joined 的线程有人收尸,资源回收
  • detached
    :不需要 join,资源自动回收

7. cancel 的完整流程

 pthread_cancel(tid)` 调用后:

  1. 内核给目标线程标记一个 “pending cancel”
  2. 目标线程在到达 cancellation point 时检查标记
  3. 如果 cancelstate 是 ENABLE 且 type 是 DEFERRED → 触发取消
  4. 按 LIFO 倒序执行所有 pthread_cleanup_push 注册的 handler
  5. 调用所有 TLS destructor
  6. 线程退出(相当于 pthread_exit(PTHREAD_CANCELED))

这条链路上任何一步崩了(比如 cleanup handler 自己抛异常),结果是 UB。所以 cleanup handler 必须简单、不阻塞、不抛错


8. 总结表

函数
用途
必须配对/注意
pthread_create
创建线程
之后必须 join 或 detach
pthread_join
等退出 + 拿返回值 + 回收
跟 create 配对
pthread_detach
不等,自动回收
跟 create 配对(二选一)
pthread_exit
主动退出 + 带返回值
-
pthread_self
拿自己 tid
比较用 pthread_equal
pthread_setname_np
设线程名(调试)
名字 ≤ 16 字节
pthread_cancel
请求取消
配 cleanup handler
pthread_cleanup_push/pop
资源清理 handler
必须同作用域
pthread_setcancelstate
启停 cancel
enable/disable
pthread_setcanceltype
deferred/async
async 危险,别用
pthread_testcancel
显式检查 cancel
纯 CPU 循环里用
pthread_once
一次性初始化
配 PTHREAD_ONCE_INIT
pthread_key_create
创建 TLS key
注册 destructor
pthread_setspecific
 / getspecific
写/读 TLS
配 once 初始化 key

9. 最容易踩的 6 个坑

  1. arg 生命周期:传栈变量给 detached 线程,主线程出栈后 worker 读到垃圾。要么 malloc,要么保证主线程比子线程活久。

  2. 不 join 也不 detach:线程退出后资源永远不回收,俗称"僵尸线程"。

  3. double join:同一个 tid join 两次是 UB。join 完 tid 就失效了。

  4. cancel 后没 cleanup:mutex / 内存 / 文件描述符泄漏。有 cancel 一定要有 cleanup_push

  5. cleanup_push/pop 不在同一作用域:编译报错(底层是宏 + 局部变量)。

  6. pthread_t 类型假设:不要假设它是 int 或 unsigned long,跨平台用 pthread_equal 比较。


10. 收尾

线程的核心 API 不多,难的是配对纪律

  • create
     配 join 或 detach
  • lock
     配 unlock(会在第二篇细讲)
  • cancel
     配 cleanup_push
  • key_create
     配 destructor

任何一对配偏了,都是潜在的资源泄漏或死锁。

把这 14 个函数掌握,普通工程的多线程需求 90% 能搞定。剩下 10%(高性能调度、特殊信号处理、跨进程同步)才需要进一步学 attr 细节、信号、共享内存、futex 等。

请在微信客户端打开

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 09:16:19 HTTP/2.0 GET : https://f.mffb.com.cn/a/501342.html
  2. 运行时间 : 0.171888s [ 吞吐率:5.82req/s ] 内存消耗:4,863.08kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=0406adb60ad437cb449d913c0d9a08d9
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000892s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001556s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000677s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000868s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001247s ]
  6. SELECT * FROM `set` [ RunTime:0.004908s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001553s ]
  8. SELECT * FROM `article` WHERE `id` = 501342 LIMIT 1 [ RunTime:0.006343s ]
  9. UPDATE `article` SET `lasttime` = 1783041379 WHERE `id` = 501342 [ RunTime:0.028750s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.001640s ]
  11. SELECT * FROM `article` WHERE `id` < 501342 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.021086s ]
  12. SELECT * FROM `article` WHERE `id` > 501342 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001211s ]
  13. SELECT * FROM `article` WHERE `id` < 501342 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.007715s ]
  14. SELECT * FROM `article` WHERE `id` < 501342 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003373s ]
  15. SELECT * FROM `article` WHERE `id` < 501342 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.002705s ]
0.175685s