I've push a changeset and macintosh plugins onto the server, they should appear in a few days.
The SerialExtendedMacOS9Plugin.sit goes in the mac 3.5 noncarbon plugin location The SerialExtendedUnixPlugin.bundle goes in the mac 3.5 carbon plugin location {yes the name implies unix, but os-x is unix...} The EnhancedSerialPorts-JMM changeset which is the classes and plugin interface logic you need to file in.
I suspect usage will be limited but it enables you to do things with serial ports (and file handles, hint any file handle) that you can't do otherwise. I would think to compile this code on your favorite Linux box that would be a snap.
Only one platform specific primitive or method exists serialPortFindNamesPlusKeysstorage which on os-x invokes the IOServiceGetMatchingServices() call to get path names to devices that support the serial protocols. This primitive call a common Linux box could be replaced by smalltalk code to iterate over /dev or read some sort of control file etc to figure out the path names to the serial devices. For mac os-9 this functionality was already part of the VM. I'm hoping that no platform specific C code will be required for unix boxes. Alas windows users require someone to do the dirty work if you want windows specific serial calls? Or will unix emulation somewhere/how etc work? Couldn't speak for parallel ports, never even occurred to me to investigate till now.
I should point out that Dan Ingalls Dan@SqueakLand.org was kind enough to actually fund with real USA $ some of the work required to build this plugin, then willing to release it to the public. So enjoy, and thank Dan for motivating ($) me to write the code and for releasing it.
PS I won't pass up an opportunity to point out if you've an obscure macintosh specific feature you would like and like Dan have a bit of cash to pay for it, then we should talk.
-- ======================================================================== === John M. McIntosh johnmci@smalltalkconsulting.com 1-800-477-2659 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===
This change prevents the following failure case where you can create a socket before initializing the network which then causes the VM to core dump after a save/restart when it attempts to destroy the socket say as a result of weak reference cleanup.
This won't work on the macintosh VMs because another check fails the socket creation because OpenTransport isn't initialized yet, and I did roll the fix into the macintosh vm 3.5.1b4 because it uses the unix socket code now. But you alert Unix/Linux users might want to try this and see what happens.
Anyone know what Windows does?
| socket | socket _ Socket newTCP. socket listenOn: 44444 backlogSize: 4. ^socket
this gives you
semaphore: a Semaphore() socketHandle: a ByteArray(0 0 0 0 0 0 0 0 2 96 51 16) /*Note how session id is ZERO */ readSemaphore: a Semaphore() writeSemaphore: a Semaphore() primitiveOnlySupportsOneSemaphore: false
Now save the image, restart, then issue a destroy on that Socket and BOOM {I'll note sometimes I don't get a crash but the debugging malloc code complains about an invalid free, or double free since the privateptr is bogus but read/writeable...}
I got this because KomServices does this. TcpListener>>newListener: backlogSize "Create a new socket that listens on our port. The backlog is how many simultaneous connections to accept at the same time"
[^self pvtNewListener: backlogSize] on: Error do: [].
"Try one more time after initializing the network" Socket initializeNetwork. ^self pvtNewListener: backlogSize.
TcpListener>> pvtNewListener: backlogSize "Create a new socket that listens on our port. The backlog is how many simultaneous connections to accept at the same time"
| listener | listener := self socketClass newTCP. self socketsToDestroy add: listener. listener listenOn: portNumber backlogSize: backlogSize. ^listener
I have to wonder if an accept can occur and we can get a socket created with a zero session id too?
New unix code should look like below. Can't speak for what the windows code should look like, but the key is that thisNetSession should NOT be zero when we run this check.
/* answer whether the given socket is valid in this net session */
static int socketValid(SocketPtr s) { if ((s != 0) && (s->privateSocketPtr != 0) && (s->sessionID == thisNetSession) && (thisNetSession != 0)) return true; interpreterProxy->success(false); return false; }
Will need someone to approve and make the unix code changes... -- ======================================================================== === John M. McIntosh johnmci@smalltalkconsulting.com 1-800-477-2659 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===
It looks like no one but John has yet made any change relating to this problem; should we? It looks a simple enough change but I'm vague enough about sockets to not know whether it is sufficient.
Well Ian did a stealth change awhile back. static int socketValid(SocketPtr s) { if (s && s->privateSocketPtr && thisNetSession && (s->sessionID == thisNetSession)) return true; interpreterProxy->success(false); return false; }
Note the addition of && thisNetSession check which fixes the problem. versus the older code which was:
static int socketValid(SocketPtr s) { if ((s != 0) && (s->privateSocketPtr != 0) && (s->sessionID == thisNetSession)) return true; interpreterProxy->success(false); return false; }
This is the WIndows code (I think) / ************************************************************************ ***** SocketValid: Validate a given SocketPtr ************************************************************************ *****/ static int SocketValid(SocketPtr s) { if ((s != NULL) && (s->privateSocketPtr != NULL) && (s->sessionID == thisNetSession)) { return true; } else { FAIL(); return false; } }
Someone (I sure there is a windows user out there somewhere?) could try the suggested failure case (attached below) and see if this problem happens on the windows side? Since the copy of the windows code I have looks like the old faulty Unix code.
On May 11, 2004, at 12:24 PM, tim@sumeru.stanford.edu wrote:
It looks like no one but John has yet made any change relating to this problem; should we? It looks a simple enough change but I'm vague enough about sockets to not know whether it is sufficient.
Original note
This change prevents the following failure case where you can create a socket before initializing the network which then causes the VM to core dump after a save/restart when it attempts to destroy the socket say as a result of weak reference cleanup.
This won't work on the macintosh VMs because another check fails the socket creation because OpenTransport isn't initialized yet, and I did roll the fix into the macintosh vm 3.5.1b4 because it uses the unix socket code now. But you alert Unix/Linux users might want to try this and see what happens.
Anyone know what Windows does?
| socket | socket _ Socket newTCP. socket listenOn: 44444 backlogSize: 4. ^socket
this gives you
semaphore: a Semaphore() socketHandle: a ByteArray(0 0 0 0 0 0 0 0 2 96 51 16) /*Note how session id is ZERO */ readSemaphore: a Semaphore() writeSemaphore: a Semaphore() primitiveOnlySupportsOneSemaphore: false
Now save the image, restart, then issue a destroy on that Socket and BOOM {I'll note sometimes I don't get a crash but the debugging malloc code complains about an invalid free, or double free since the privateptr is bogus but read/writeable...}
I got this because KomServices does this. TcpListener>>newListener: backlogSize "Create a new socket that listens on our port. The backlog is how many simultaneous connections to accept at the same time"
[^self pvtNewListener: backlogSize] on: Error do: [].
"Try one more time after initializing the network" Socket initializeNetwork. ^self pvtNewListener: backlogSize.
TcpListener>> pvtNewListener: backlogSize "Create a new socket that listens on our port. The backlog is how many simultaneous connections to accept at the same time"
| listener | listener := self socketClass newTCP. self socketsToDestroy add: listener. listener listenOn: portNumber backlogSize: backlogSize. ^listener
I have to wonder if an accept can occur and we can get a socket created with a zero session id too?
New unix code should look like below. Can't speak for what the windows code should look like, but the key is that thisNetSession should NOT be zero when we run this check.
/* answer whether the given socket is valid in this net session */
static int socketValid(SocketPtr s) { if ((s != 0) && (s->privateSocketPtr != 0) && (s->sessionID == thisNetSession) && (thisNetSession != 0)) return true; interpreterProxy->success(false); return false; }
Will need someone to approve and make the unix code changes... -
-- ======================================================================== === John M. McIntosh johnmci@smalltalkconsulting.com 1-800-477-2659 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===
On 20/06/03 01:08, "John M McIntosh" johnmci@smalltalkconsulting.com wrote:
PS I won't pass up an opportunity to point out if you've an obscure macintosh specific feature you would like and like Dan have a bit of cash to pay for it, then we should talk.
What about having in Squeak something like this I copy from F-Script ?
"Instantiate and configure a window" window := NSWindow alloc initWithContentRect:(125<>513 extent:400<>200) styleMask:NSTitledWindowMask + NSClosableWindowMask + NSMiniaturizableWindowMask + NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO. "Put the window on screen" window orderFront:nil. "Give a title to the window" window setTitle:'Currency Converter'.
Too hard ? I volunteer for test any code .
Any way , many thanks to you, Dan, and others.
edgar
On Thursday 19 June 2003 09:08 pm, John M McIntosh wrote:
I've push a changeset and macintosh plugins onto the server, they should appear in a few days.
Where would that be? I'm finally ready to get this working under Linux.
I can't find the change set in the SF CVS tree. And I couldn't find a link to it on your site.
The latest you posted to the list was EnhancedSerialPorts-JMM.11.cs.gz; is there a more recent version somewhere?
Thanks,
squeak-dev@lists.squeakfoundation.org