logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
ExportSingleCharacter()

 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
PlasmaJohn



Joined: 04 Mar 2005
Posts: 70
Location: The Garage

PostPosted: Tue Sep 15, 2009 15:46    Post subject: ExportSingleCharacter() Reply with quote

As noted in this thread on the Higher Ground forums the ExportSingleCharacter() NWScript call returns immediately and performs the save in the background. We ran into this issue when testing my new Vaultster rewrite for Linux. We also noticed this happening on the Windows side if the bic was too large.

Anybody know if nwserver uses file locking on both Windows and Linux? If so, what style?

Thanks
Back to top
View user's profile Send private message
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Tue Sep 15, 2009 21:20    Post subject: Reply with quote

... eww. And I was pretty convinced that it was synchronous, based on how often Win32 Vaultster worked.

Yeah, ExportSingleCharacter just sets an "export this character" flag, which is later handled by CServerExoAppInternal::ExportPlayer(), and more specifically CNWSPlayer::SaveServerCharacter(), and MORE specifically CNWSPlayer::BackupServerCharacter(), which includes the strings "rb" and "wb"... from there it's pretty straightforward.

Unfortunately, it appears the locking only happens while the file write is occurring. Perhaps the best approach would be a hook on the export function to call back to a script when CServerExoAppInternal::ExportPlayer() is done. I'll take a look, but I haven't done any script callback hooking, so there's some knowledge to be acquired first.

CServerExoAppInternal::ExportPlayer() is 456A40 on Win32, 80AFF10 on Linux.
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Tue Sep 15, 2009 22:22    Post subject: Reply with quote

Not actually sure if this solves the problem in question, but what about using inotify (on Linux, Windows has something equivalent - I hope) to monitor things, and just copy the stuff that changes? Just let the kernel do the work for you.
Back to top
View user's profile Send private message
PlasmaJohn



Joined: 04 Mar 2005
Posts: 70
Location: The Garage

PostPosted: Tue Sep 15, 2009 22:45    Post subject: Reply with quote

Zebranky wrote:
Unfortunately, it appears the locking only happens while the file write is occurring.

That's fine if they're using an OS file lock, in that case I can just poll the lock status myself. If they are using one on Linux, hopefully it isn't flock() which is not compatible with NFS (according to one manpage)

elven wrote:
Not actually sure if this solves the problem in question, but what about using inotify (on Linux, Windows has something equivalent - I hope) to monitor things, and just copy the stuff that changes? Just let the kernel do the work for you.

Thanks, I'll look into it.
Back to top
View user's profile Send private message
elven



Joined: 28 Jul 2006
Posts: 259
Location: Germany

PostPosted: Tue Sep 15, 2009 22:51    Post subject: Reply with quote

FWIW, I don't think the Linux server uses locking at all. It just, sort of, well, overwrites the old file.
Back to top
View user's profile Send private message
PlasmaJohn



Joined: 04 Mar 2005
Posts: 70
Location: The Garage

PostPosted: Tue Sep 15, 2009 23:01    Post subject: Reply with quote

Re: inotify

Nice! IN_CLOSE_WRITE will work just dandy for me.

Horridly non-portable unfortunately. Hm... pnotify is an attempt to create a portable version on top of inotify , kqueue and the NTFS Change Journal. A quick glance through the documentation doesn't show anything as nice as IN_CLOSE_WRITE.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group