日期:2014-05-16 浏览次数:20731 次
lighttpd 在接收到上传数据(PUT/POST),会生成大小为1M的很多临时文件。
线上最近有很多上传请求,lighttpd 经常报警,说上传的临时文件丢失,
起初怀疑是被其它程序删除,后来勇哥提到,会不会是我们生成临时文件的方法有问题,生成了重名的临时文件?
查了lighttpd 的实现,使用的是mktemp函数:
http://linux.die.net/man/3/mktemp If the call was successful, the last six bytes of template will have been modified in such a way that the resulting name is unique (does not exist already). If the call was unsuccessful, template is made an empty string. Never use mktemp(). Some implementations follow 4.3BSD and replace XXXXXX by the current process ID and a single letter, so that at most 26 different names can be returned. The tempnam() function is re-entrant while mktemp() isn't 不可重入,可能两个进程产生同一个文件名 |