Comments (1)
ngx_http_lua_run_thread 源码( ngx.thread 调度部分)
ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
952 ngx_http_lua_ctx_t *ctx, volatile int nrets)
953 {
954 ...
973 NGX_LUA_EXCEPTION_TRY {
974 ...
982 for ( ;; ) {
983 ...
997 orig_coctx = ctx->cur_co_ctx;
998 ...
1015 rv = lua_resume(orig_coctx->co, nrets);//通过lua_resume执行协程中的函数
1016 ...
1032 switch (rv) {//处理lua_resume的返回值
1033 case LUA_YIELD:
1034 ..
1047 if (r->uri_changed) {
1048 return ngx_http_lua_handle_rewrite_jump(L, r, ctx);
1049 }
1050 if (ctx->exited) {
1051 return ngx_http_lua_handle_exit(L, r, ctx);
1052 }
1053 if (ctx->exec_uri.len) {
1054 return ngx_http_lua_handle_exec(L, r, ctx);
1055 }
1056 switch(ctx->co_op) {
1057 ...
1167 }
1168 continue;
1169 case 0:
1170 ...
1295 continue;
1296 ...
1313 default:
1314 err = "unknown error";
1315 break;
1316 }
1317 ...
1444 }
1445 } NGX_LUA_EXCEPTION_CATCH {
1446 dd("nginx execution restored");
1447 }
1448 return NGX_ERROR;
1449
1450 no_parent:
1451 ...
1465 return (r->header_sent || ctx->header_sent) ?
1466 NGX_ERROR : NGX_HTTP_INTERNAL_SERVER_ERROR;
1467
1468 done:
1469 ...
1481 return NGX_OK;
1482 }```
from blog.
Related Issues (20)
- Go 常用库源码探究
- Nginx 获取客户端 IP 的几种方式
- Nginx keepalive_requests 踩坑总结
- Go 依赖管理
- 深入理解 Go 调度器
- 面试汇总
- 参加 OpenResty Con 2018
- Nginx reload 端口占用问题分析
- Go unsafe 包探究
- Nginx 缓存实践与实现讨论
- OpenResty 转发请求超时问题分析报告
- TCP 拥塞控制算法
- 分布式锁的实现及原理 HOT 2
- 事务应用与原理
- 规则引擎的实现
- json.Unmarshal 奇怪的坑 HOT 1
- Go 程序性能分析过程 HOT 1
- Raft 协议原理与在 Etcd 中的实践
- http请求体结束
- Organization Chart for Zoho CRM
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.