Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Learning more about descriptors...
Learning more about descriptors...
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Sun 19 Jan 2003 04:31 AM (UTC) |
Message
| I really am a newbie coder that just learned how to do everything by messing with it and figuring out what it meant(and reading some books on C coding, but I believe you don't get the gist of coding till you have really messed with some code). Anyways, I was reading about the entire descriptor deal and I was just saying to myself "Hey, I've looked through that code, but I don't really under stand what it all means.." So, yeah, if you would could you explain in short what descriptors in the MUD are really about, becaue all I know is that you need them to log on and everything.
The second thing I have to say is how nice I think it is that everyone is so helpful on this forum. I think its great we can just post our problems with our code and have other people that are kind enough to help up figure it out. Anyways, I just thought i would say thanks to anyone and everyone who reads, posts, admin's this forum.
Thanks for everything. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Nick Gammon
Australia (23,057 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sun 19 Jan 2003 05:25 AM (UTC) |
Message
| When you open a file, or create a TCP/IP connection with a socket, the operating system gives you a number, which is its internal reference to that file. This can be called a file descriptor (I think Windows calls it a handle, but a rose by any other name ...).
You subsequently use this descriptor to access the file (eg. read, write, close, query, etc.). The operating system looks it up in its internal table to see which file you are talking about.
In SMAUG, which is mainly TCP/IP I/O (plus some disk files) the term descriptor generally refers to a connected player, and hence the file descriptor returned by the OS when the connection is established. Somewhat confusingly the low-level operating system descriptor is stored in an internal structure called descriptor_data, which stores the OS descriptor, plus other things that are useful, such as incoming data that hasn't been processed yet (eg. because no linefeed), outgoing data yet to be sent, and so on. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,057 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sun 19 Jan 2003 05:26 AM (UTC) |
Message
| See mud.h for that structure.
And by the way, thanks for the compliments about the forum. Glad you find it useful. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #3 on Sun 19 Jan 2003 06:32 AM (UTC) |
Message
| A little more info on descriptors..
In a native *nix environment you can see what descriptors a particular program may have open quite easily.
First type 'ps x' You'll get a list of processes your shell user has running. It'll look like a list of these:
15728 pts/12 S 0:01 gdb ../src/smaug
That first number is your pid (Process Id). With that number on hand, change to your /proc directory.
Typing 'ls' you'll see an extensive list of numbers and other seemingly cryptic things. One of those numbers will correspond to your mud's pid. It is in fact, a directory. Change to that directory. In this case, I would type 'cd 15728'.
You'll enter another directory full of files all related to that pid. One of those directories is called 'fd'. Change to that directory. Within that directory will be a *hopefully* medium range of numbers. Each one of those numbers represents a file descriptor your mud is using. It could be a file the mud has open or a 'socket' that's open (someone who's connected). There are also a number of system reserved/used file descriptors.
Typing 'ls -l' will give you a more detailed listing. Like such:
[thresher@users: fd]$ ls -l
total 0
lrwx------ 1 thresher users 64 Jan 19 00:15 0 -> /dev/pts/4 (deleted)
l-wx------ 1 thresher users 64 Jan 19 00:15 1 -> /home/thresher/smaug/dist/log/122.log
lrwx------ 1 thresher users 64 Jan 19 00:15 10 -> socket:[2733641]
l-wx------ 1 thresher users 64 Jan 19 00:15 2 -> /home/thresher/smaug/dist/log/122.log
lr-x------ 1 thresher users 64 Jan 19 00:15 3 -> /dev/null
lr-x------ 1 thresher users 64 Jan 19 00:15 4 -> /dev/null
lrwx------ 1 thresher users 64 Jan 19 00:15 5 -> socket:[2726550]
lrwx------ 1 thresher users 64 Jan 19 00:15 8 -> socket:[2734964]
[thresher@users: fd]$
Looking at this you can see what files the process has open currently and the number of sockets connected. You'll notice that the number listed here corresponds to the descriptor number of a connected user.
This list can also be very handy in tracking down potential 'descriptor leaks'. A descriptor leak is caused by the program opening a file but not closing it. If you see a list of files here pointing at player files for example. You likely have a problem somewhere.
I hope this has expanded your knowledge of descriptors a bit. More then likely I just confused you more ;-) | Top |
|
Posted by
| Nick Gammon
Australia (23,057 posts) Bio
Forum Administrator |
Date
| Reply #4 on Sun 19 Jan 2003 10:28 AM (UTC) |
Message
| This /proc stuff seems to work perfectly on Linux, however I can't get it to work on OS/X, and I think from memory it doesn't work under OpenBSD also.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #5 on Tue 21 Jan 2003 12:03 AM (UTC) |
Message
| Indeed. The /proc thing works very well under Linux. I've uncovered a few descriptor leaks using that method in some of the extra stuff we have in our code. You need to be especially mindful of those when using copyover since it carries over leaked ones along with your active ones. Needless to say if you leak enough of them this will cause you a world of hurt. Plugging them can be somewhat of a pain too. :) | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #6 on Tue 21 Jan 2003 06:25 AM (UTC) |
Message
| The best thing to do when you're having an abundance of descriptor leaks, is to just start with the first file you have, search for an instance of 'fopen' and verify that whatever was opened, gets closed again. Continue doing this until you've gone through all of your files that have and fopen's in them. Sounds painful, but the alternative if you don't bring the situation under control can be much worst. | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #7 on Tue 21 Jan 2003 09:04 AM (UTC) |
Message
| Was talking about open sockets actually. Not file handles. And I've at least traced down that they're coming out of the webserver module. Which I suppose was to be expected since the descriptor handling isn't the best in there. At least I've stopped it from bleeding past a copyover. :) | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #8 on Wed 22 Jan 2003 12:52 AM (UTC) |
Message
| Another question I think fits in here. Whats up with copyover for SWR. It lags the login screen so you don't even see the intro screen. Any ideas on why it does that?
Thanks. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #9 on Wed 22 Jan 2003 01:12 AM (UTC) |
Message
| You confuse me a bit. Every version of copyover I've seen has had nothing to do with a login or intro. It's merely a save of who's connected and where they are located (and in the case of Samson's hotboot code, object and mobile positions too). So that when the copyover is complete, everything is put back were it was and the player experiences nothing more then what seems like a brief moment of bad lag. If you took out all of the messages too the player, most wouldn't likely even know a reboot occured. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #10 on Wed 22 Jan 2003 08:50 PM (UTC) |
Message
| What I meant was that after I reboot and try to login with a differen't name the "help greeting" file doesn't even show up. It just says connected, its like horrible login lag. I hope that helps because its a weird problem. Anyways, thanks for the help. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #11 on Fri 24 Jan 2003 12:35 PM (UTC) |
Message
| Not sure why SWR would bomb that way on a copyover, but it sounds like there's definitely some kind of problem. Not having worked with it before, I can't say for sure what the cause is. Which version of SWR? Perhaps if I get bored I'll look at it. Also, which version of copyover? :) | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #12 on Fri 24 Jan 2003 05:39 PM (UTC) |
Message
| Describe what happens during a copyover and right after, as well as what happens when you try to log on. By the way I understand it, the copyover works right, but when you or anyone else attmpts to log on to your mud after a copyover the 'greeting' screen is no displayed. Am I correct in this? If that's the case I have at least a partial idea what may be causing it. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #13 on Sat 25 Jan 2003 04:17 AM (UTC) |
Message
| Sorry, forgot to check the forum for replies for a few days. Anyways, yes, that is the exact problem, it works fine but the 'Greeting' help file does not show up when you try to log on. It just says you are connected. And to answer your question Samson, its the copyover snippet from Kyndig. Its under snippets. Here is the URL:
http://www.kyndig.com/codes/diku/merc/smaug/Star_Wars
Anyways, sorry for the delay. Thanks for all the help. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #14 on Sat 25 Jan 2003 05:02 AM (UTC) |
Message
| Two questions. What client do you use? and Even though the greeting doesn't display, can you still log on by typing your name and such? Also, open up comm.c and in:
void new_descriptor()
look for this chunk of code:
/*
* Send the greeting.
*/
{
extern char * help_greeting;
if ( help_greeting[0] == '.' )
write_to_buffer( dnew, help_greeting+1, 0 );
else
write_to_buffer( dnew, help_greeting , 0 );
}
If you can still log on and that code is not there, see if you can locate something similar to it. But, if by chance you can't even log on properly, you have a much worst situation (you may have skipped a part in the snippet). | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
60,152 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top