eclipse - SSH(FTP)和Web服务器并发文件IO

标签 eclipse apache concurrency ssh ftp

我有一个带有 Apache 的服务器。

我在对一个文件进行并发读写操作时遇到问题。

假设我在 Apache DocRoot 中有 index.html 文件。在浏览器中我可以打开阅读它。

我正在使用 Eclipse IDE 通过 SSH(或 FTP)直接修改服务器上的文件。 对文件进行一些更改后,我将其上传到服务器。上传需要一些时间。

问题是:如果我尝试在浏览器中查看文件,而文件正在上传,则上传挂起并且目标文件变为空白。看起来 apache 和 SSH 服务器都试图访问文件,SSH 写入,Apache 读取。碰撞打破了一切。

有什么办法可以避免这种情况吗?也许是一些 SSH 服务器配置选项或 Apache 模块?

最佳答案

您需要先锁定文件。你知道你使用什么操作系统和apache配置吗,是你自己的系统吗?

这里引用了 apache 服务器文档:

EnableMMAP Directive


Description:
Use memory-mapping to read files during delivery 

Syntax:
EnableMMAP On|Off 

Default:
EnableMMAP On 

Context:
server config, virtual host, directory, .htaccess 

Override:
FileInfo 

Status:
Core 

Module:
core 

This directive controls whether the httpd may use memory-mapping if it needs to read the contents of a file during delivery. By default, when the handling of a request requires access to the data within a file -- for example, when delivering a server-parsed file using mod_include -- Apache httpd memory-maps the file if the OS supports it.

This memory-mapping sometimes yields a performance improvement. But in some environments, it is better to disable the memory-mapping to prevent operational problems:
•On some multiprocessor systems, memory-mapping can reduce the performance of the httpd.
•Deleting or truncating a file while httpd has it memory-mapped can cause httpd to crash with a segmentation fault. 

For server configurations that are vulnerable to these problems, you should disable memory-mapping of delivered files by specifying:
EnableMMAP Off

For NFS mounted files, this feature may be disabled explicitly for the offending files by specifying:

  EnableMMAP Off

由于您的服务器崩溃了,我怀疑您为文件所在的目录“设置”了此选项。

添加

AllowMMAP Off

到您目录的 .htaccess 文件。

关于eclipse - SSH(FTP)和Web服务器并发文件IO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18146925/

相关文章:

java - NoClassDefException,从另一个包开始 Activity

linux - Apache 重定向 (.htaccess)

apache - 为什么 files 指令在 Apache 的 httpd.conf 中不起作用?

java - 线程间的并发问题

java - 信号量 - 为什么我的线程一个接一个地运行而不是并发运行?

java - 更紧凑的 Eclipse 自动完成代码

java - Clojure Swing 异常 "No implementation of method: :children"

android - 找不到接口(interface)的 Binder

Apache 反向代理 : handle SSLCertificateFile on proxy and SSLCACertificateFile on proxyed host

python - 使用 pytest 同时运行 celery 任务