简体   繁体   English

DLL注入/ IPC问题

[英]DLL Injection/IPC question

I'm work on a build tool that launches thousands of processes (compiles, links etc). 我正在使用一个可启动数千​​个进程(编译,链接等)的构建工具。 It also distributes executables to remote machines so that the build can be run accross 100s of slave machines. 它还将可执行文件分发到远程计算机,以便可以跨100个从属计算机运行该构建。 I'm implementing DLL injection to monitor the child processes of my build process so that I can see that they opened/closed the resources I expected them to. 我正在实现DLL注入以监视构建过程的子进程,以便可以看到它们打开/关闭了我期望它们的资源。 That way I can tell if my users aren't specifying dependency information correctly. 这样,我可以判断用户是否未正确指定依赖项信息。

My question is: 我的问题是:

I've got the DLL injection working but I'm not all that familiar with windows programming. 我已经完成了DLL注入的工作,但是我对Windows编程并不那么熟悉。 What would be the best/fastest way to callback to the parent build process with all the millions of file io reports that the children will be generating? 用子代将生成的数百万个文件io报告,回调到父代构建过程的最佳/最快方法是什么? I've thought about having them write to a non-blocking socket, but have been wondering if maybe pipes/shared memory or maybe COM would be better? 我曾考虑过让它们写入非阻塞套接字,但一直想知道也许管道/共享内存或COM会更好吗?

If you stay in the windows world (None of your machines is linux or whatever) named pipes is a good choice, because it is fast and can be accessed across the machine boundary. 如果您停留在Windows世界(您的机器都不是linux或其他机器)中,则命名管道是一个不错的选择,因为它速度很快并且可以跨机器边界访问。 I think shared memory is out of the race, because it can't cross the machine boundary. 我认为共享内存已经不合时宜了,因为它无法跨越计算机边界。 Distributed com allows to formulate the contract in IDL, but i think XML Messages via pipes are also ok. 分布式com允许在IDL中制定合同,但我认为通过管道的XML消息也可以。 The xml messages have the benefit to work completely independent from the channel. xml消息的好处是可以完全独立于通道工作。 If yo need linux later you can switch to tcp/ip transport and send your xml messages. 如果您以后需要linux,则可以切换到tcp / ip传输并发送xml消息。

Some additional techniques with limitations: 一些其他技术有局限性:

Another forgotten but hot candidate is RPC (remote procedure calls). 另一个被遗忘但热门的候选人是RPC(远程过程调用)。 Lot of windows services rely on this. 许多Windows服务都依赖于此。 But i think it is hard to program RPC 但我认为编写RPC很难

If you are on the same machine and you only need to send some status information, you can regisier a windows message via RegisterWindowMessage() and send messages vie SendMessage() 如果您在同一台计算机上,并且只需要发送一些状态信息,则可以通过RegisterWindowMessage()注册Windows消息,并发送消息vie SendMessage()

First, since you're apparently dealing with communication between machines, not just within one machine, I'd rule out shared memory immediately. 首先,由于您显然要处理机器之间的通信,而不仅仅是在一台机器内,因此我会立即排除共享内存。

I'd think hard about trying to minimize the amount of data instead of worrying a lot about how fast you can send it. 我会努力尝试尽量减少数据量,而不必担心发送速度有多快。 Instead of sending millions of file I/O reports, I'd batch together a few kilobytes of that data (or something on that order) and send a hash of that packet. 我没有发送数百万个文件I / O报告,而是将几千字节的数据(或按顺序排列的东西)打包在一起,然后发送该数据包的哈希。 With a careful choice of packet size, you should be able to reduce your data transmission to the point that you can simply use whatever method you find most convenient, rather than trying to pick the one that's the fastest. 通过仔细选择数据包大小,您应该能够减少数据传输,以至于您可以简单地使用您认为最方便的任何方法,而不是尝试选择最快的方法。

apart from all the suggestions from thomas, you might also just use a common database to store the results. 除了托马斯提出的所有建议外,您可能还只是使用一个公共数据库来存储结果。 And if that is too slow use one of the more modern(and fast) key/value databases (like tokyo cabinet/memcachedb/etc). 如果太慢,请使用更现代(更快速)的键/值数据库之一(例如tokyo cabinet / memcachedb / etc)。

This sounds like a lot of overkill for the task of verifying the files used in a build. 对于验证构建中使用的文件的任务来说,这听起来有些过高。 How about, just scanning the build files? 怎么样,只扫描构建文件? or capturing the output from the build tools? 或捕获构建工具的输出?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM