[Vm-dev] netstyle.ch, Cog, systemd, and Socket>>initialize:

Chris Cunnington brasspen at gmail.com
Wed Dec 3 15:22:30 UTC 2014

In July netstyle.ch said some exciting things about systemd and socket activation. [1] I have an observation and a question. 
The observation is that to set Real Time Priority pursuant of the README for Cog you need to add the following in your Service or you will not be able to start coglinuxht. [2] 


The question concerns the code in the systemd.cs file [4] which I don't think can work because it calls a non-existant primitive in the SocketPlugin. I suspect netstyle.ch wrote its patch for a very old virtual machine, one that still used #primitiveSocketCreate3Semaphores, which I don't think exists in contemporary SocketPlugin code. [3] In the image, there remain references to this non-existant primitive. They are employed by code in the systemd.cs file.[4] The culprit is Socket>>initialize: used in Socket class>>newSystemd. 

So, Max, my question is, did you at netstyle.ch find a solution for this? 
Does anybody have an idea of how to re-route Socket>>initialize: towards a primitive that actually exists? 


[1] http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-July/179015.html <http://lists.squeakfoundation.org/pipermail/squeak-dev/2014-July/179015.html>
[2] http://www.freedesktop.org/software/systemd/man/systemd.exec.html <http://www.freedesktop.org/software/systemd/man/systemd.exec.html>
[3] http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/unix/ <http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/unix/>
[4] contents of the systemd.cs file [1]: 
'From Pharo1.3 of 16 June 2011 [Latest update: #13315] on 4 July 2014 at 3:20:20 pm'!

!TcpListener methodsFor: '*systemd' stamp: 'nl 07/04/2014 15:17'!
	"LISTEN_FDS is set by systemd if the process/pharo-vm is started via port activation"
	^ (self primEnvironmentAtSymbol: 'LISTEN_FDS') 
		ifNotNilDo: [ :value | value asNumber = 1 ] 
		ifNil: [ false]! !

!TcpListener methodsFor: '*systemd' stamp: 'nl 07/04/2014 15:18'!
pvtNewListener: backlogSize 
	"Create a new socket that listens on our port.  The backlog is how many simultaneous 
	connections to accept at the same time

	Use the socket assigned by systemd if:
	- the command-line port number is equal to the portNumber to be opened
	- there is an environment variable LISTEN_FDS with value 1
	Otherwise use normal port allocation.
	| listener |
	listener := (self haveSystemdAssignedPort
		ifTrue: [ self socketClass newSystemd ]
		ifFalse: [ self socketClass newTCP ]).
	self socketsToDestroy add: listener.
		bind: listener
		withBacklogSize: backlogSize.
	^ listener! !

!TcpListener methodsFor: '*systemd' stamp: 'nl 04/29/2013 14:04'!
primEnvironmentAtSymbol: aSymbol
	"Copy-paste from UnixOSProcessPlugin: Answer the value of an environment variable in the external OS process."
	<primitive: 'primitiveEnvironmentAtSymbol' module: 'UnixOSProcessPlugin'>
	^ nil ! !

!Socket class methodsFor: '*systemd' stamp: 'nl 07/04/2014 15:23'!
	"Create a socket assigned by systemd port activation"
	| SystemdSocketType |
	SystemdSocketType := 2.
	self initializeNetwork.
	^[ super new initialize: SystemdSocketType ]
		repeatWithGCIf: [ :socket | socket isValid not ]! !

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141203/ea793e27/attachment.htm

More information about the Vm-dev mailing list