View Single Post
Old 08-15-2005, 07:51 PM   #8
Yui Unifex
Senior Member
 
Join Date: Apr 2002
Location: Florida
Posts: 323
Yui Unifex is on a distinguished road
Send a message via ICQ to Yui Unifex Send a message via AIM to Yui Unifex
Question

Copyover is a fairly simple concept. It is customary for open files to be inherited when executing a new process, and since sockets are just another kind of file to read and write, they are inherited as well. The 'file abstraction' is a fundamental concept which contributes to the simplicity of UNIX systems.

So here's a basic rundown of what a mud will do:
1) Copyover is initiated.
2) All transient state is written somewhere.
2a) This always includes a section for the file descriptor number and player name (or other unique identifier).
2b) The server file descriptor should also be written.
3) execl() is called to replace the current process image with the new code.
3a) A special flag is passed to the code to tell it to resume from a copyover.
4) When the server starts with that special flag, it reads the previously written file and recreates its structures.
5) Game resumes execution.

Don't do this. Not all of your memory is inherited, only certain parts. You want to serialize your stuff in a sane way =).

This approach is necessitated by the platform used for my current codebase, and I don't think it's anywhere near as simple or elegant as the execl() approach. The basic design of inherited open files is a fundamental part of the way UNIX works, because it allows parent processes to control restricted, doling out specific chunks to its children (e.g., the relationship between sshd and your shell.) So the execl() method is not a hack, it's simply the way things are supposed to work by design.

Oh yeah, and **** profanity filters.
Yui Unifex is offline   Reply With Quote