4 ms·
Back in the day I worked for a large computer networking company that had (for the time) really high-speed drivers for their adapter cards. I worked on the ada
by jgrahamc 17y ago
Back in the day I worked for a large computer networking company that had (for the time) really high-speed drivers for their adapter cards. I worked on the adapter card drivers writing code in C and assembler.
One of our drivers emulated the Novell IPX/SPX API on the PC and it worked great. Except for one piece of software which would crash (it was a 3270 emulator). I was task with debugging this problem.
It turned out that an optimization in our code meant that if you sent a packet to yourself it would be never actually go into the network. We'd simply immediately deliver it. The real NE2000 driver would send the packet on the network and then receive it.
This piece of software was using a packet sent to itself as a test of network connectivity and because of the way in which the code was written the packet had to be received with a short delay. Basically, the software called Send_Packet and when that API returned it would clear a flag and then it would hang around and wait for the flag to change.
The flag would be changed inside the ESR (sort of interrupt service routine) registered by the software for receiving packets.
Trouble was our optimization meant that the ESR was called while Send_Packet was executing (i.e. before it returned) and hence the flag was always zero and the software died.
The solution was... to ship our network driver with special code that I wrote that would examine the code of all programs that registered ESR for packet receipt. By examining the ESR routine code I would determine whether this particular piece of software was running and patch it to get around this problem.
(Yes, you did read that right: we shipped a network driver that would patch host software live.)
- eugenejen 17y agoThis is a monkey patch used in the right place and right time.
- Tichy 17y agoWouldn't it have been better to just send the packet to the network if said software was detected? After all, it was supposed to be a network test - hopefully at least you replaced it with another network test?
- jgrahamc 17y agoYou might think so but it wasn't possible. This was because of the architecture of our drivers which consisted of a portion running in the host machine and a portion running in the adapter card itself on an on-board processor. When the packet was handed down from the host to the adapter for transmission it was the adapter that made the decision about whether to actually transmit it or not. We could have added a flag for 'really transmit' this to the hand-off but we were obsessed with speed and memory utilization (this is back in the days of extended memory and all that fun) and so this relatively large change to our code to fix one piece of software was deemed unacceptable. And yes we did fake the network test because the adapter would give us network status so the software ended up getting the right result.
- Tichy 17y agoWhat if somebody removed your software, but kept on using the software you patched?
- inklesspen 17y agoIt was patched in memory, not on the disk.