当前位置:网站首页>Attempt to redefine 'timeout' at line 2 solution
Attempt to redefine 'timeout' at line 2 solution
2022-06-30 05:37:00 【Xiaomei】
Original code
local ffi = require("ffi")
ffi.cdef[[
struct timeval {
long int tv_sec;
long int tv_usec;
};
int gettimeofday(struct timeval *tv, void *tz);
]];
local gettimeofday_struct = ffi.new("struct timeval")
local function gettimeofday()
ffi.C.gettimeofday(gettimeofday_struct, nil)
return tonumber(gettimeofday_struct.tv_sec) * 1000000 + tonumber(gettimeofday_struct.tv_usec)
endOperation error reporting
[error] 4028#0: *5 lua entry thread aborted: runtime error: /opt/olwaf/olaccess.lua:126: attempt to redefine 'timeval' at line 2
stack traceback:
coroutine 0:
[C]: in function 'cdef'
/opt/olwaf/olaccess.lua:126: in main chunk, client: 127.0.0.1, server: www.olwaf.com, request: "POST /api/v2/dict_info HTTP/1.1", host: "www.olwaf.com"
Normal after modification
local ffi = require("ffi")
if pcall(ffi.typeof, "struct timeval") then
-- check if already defined.
else
ffi.cdef[[
typedef struct timeval {
long tv_sec;
long tv_usec;
} timeval;
int gettimeofday(struct timeval* t, void* tzp);
]]
end
local gettimeofday_struct = ffi.new("struct timeval")
local function gettimeofday()
ffi.C.gettimeofday(gettimeofday_struct, nil)
return tonumber(gettimeofday_struct.tv_sec) * 1000000 + tonumber(gettimeofday_struct.tv_usec)
end边栏推荐
- Idea of capturing mobile terminal variant combination
- pytorch中常用损失函数总结
- Word frequency statistics (string, list)
- Unity- the camera follows the player
- Unity3d- use animator and code to control task walking
- Visualization of 3D geological model based on borehole data by map flapping software
- 聲網,站在物聯網的“土壤”裏
- AI大模型落地大考,浪潮交出了怎样的答卷?
- What are membrane stress and membrane strain
- Unity shortcut key
猜你喜欢

Introduction to mmcv common APIs

We strongly recommend more than a dozen necessary plug-ins for idea development

English grammar_ Adjective / adverb Level 3 - superlative

Digital signature——

RedisTemplate 常用方法汇总

OpenCL线程代数库ViennaCL的使用

Did you know that WPS can turn on eye protection mode?

Virtual and pure virtual destructions

Rotation, translation and scaling of unity VR objects

pytorch中常用损失函数总结
随机推荐
Database SQL language 06 single line function
uboot通过终端发送‘r‘字符读取ddr内存大小
Why can transformer break into the CV world and kill CNN?
The minecraft server address cannot be refreshed.
2021-10-31
We strongly recommend more than a dozen necessary plug-ins for idea development
Unity determines whether the UI is clicked
Simple use of qlistview of QT (including source code + comments)
D. Big Brush
AI大模型落地大考,浪潮交出了怎样的答卷?
14x1.5cm vertical label is a little difficult, VFP calls bartender to print
抓取手机端变体组合思路设想
Unity Catmull ROM curve
Unity- the camera follows the player
旋转框目标检测mmrotate v0.3.1 训练DOTA数据集(二)
Access is denied encountered when vfpbs calls excel under IIS
Xi'an Jiaotong 21st autumn "computerized accounting" online homework answer sheet (I) [standard answer]
86. 分隔链表
旋转框目标检测mmrotate v0.3.1入门
East Tower attack and defense world - XSS bypasses the safety dog