9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] question about httpd
@ 2022-08-02 16:51 sahu
  2022-08-02 16:56 ` Jacob Moody
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: sahu @ 2022-08-02 16:51 UTC (permalink / raw)
  To: 9front

Hello, 

I have looked at the code, and have a question about the redirectinit() function in /sys/src/cmd/ip/httpd/redirect.c:

void
redirectinit(void)
{
	static Biobuf *b = nil;
	static Qid qid;
	char *file, *line, *s, *host, *field[3];
	static char pfx[] = "http://";

	file = "/sys/lib/httpd.rewrite";
	if(b != nil){
		if(	(Bfildes(b), &qid) == 0)
			return;
		Bterm(b);
	}
...
}

In which cases could b be nil? And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?

Many thanks in advance and best regards, 
sahu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 16:51 [9front] question about httpd sahu
@ 2022-08-02 16:56 ` Jacob Moody
  2022-08-02 17:12 ` ori
  2022-08-02 17:13 ` Kurt H Maier
  2 siblings, 0 replies; 9+ messages in thread
From: Jacob Moody @ 2022-08-02 16:56 UTC (permalink / raw)
  To: 9front

On 8/2/22 10:51, sahu@mailbox.org wrote:
> Hello, 
> 
> I have looked at the code, and have a question about the redirectinit() function in /sys/src/cmd/ip/httpd/redirect.c:
> 
> void
> redirectinit(void)
> {
> 	static Biobuf *b = nil;
> 	static Qid qid;
> 	char *file, *line, *s, *host, *field[3];
> 	static char pfx[] = "http://";
> 
> 	file = "/sys/lib/httpd.rewrite";
> 	if(b != nil){
> 		if(	(Bfildes(b), &qid) == 0)
> 			return;
> 		Bterm(b);
> 	}
> ...
> }
> 
> In which cases could b be nil? And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
> 
> Many thanks in advance and best regards, 
> sahu


Note that 'b' is declared as static, meaning it will retain it's values between calls.
So b will be nil on only the first call to this function, subsequent calls will have
a valid pointer.


---
Moody

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 16:51 [9front] question about httpd sahu
  2022-08-02 16:56 ` Jacob Moody
@ 2022-08-02 17:12 ` ori
  2022-08-02 17:13 ` Kurt H Maier
  2 siblings, 0 replies; 9+ messages in thread
From: ori @ 2022-08-02 17:12 UTC (permalink / raw)
  To: 9front

Quoth sahu@mailbox.org:
> In which cases could b be nil? And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?

The system ships with documentation.

% man Bfildes
<Bfildes manpage>
% lookman Biobuf
man 2 bio # bio(2)
man 2 object # object(2)
man 2 string # string(2)
% lookman Qid
(ok, this one gives a lot of output; you want man 5 intro)


And, nobody really said what Qid stands for, but it's just
a uniQue ID.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 16:51 [9front] question about httpd sahu
  2022-08-02 16:56 ` Jacob Moody
  2022-08-02 17:12 ` ori
@ 2022-08-02 17:13 ` Kurt H Maier
  2022-08-02 17:45   ` Jacob Moody
  2 siblings, 1 reply; 9+ messages in thread
From: Kurt H Maier @ 2022-08-02 17:13 UTC (permalink / raw)
  To: 9front

On Tue, Aug 02, 2022 at 06:51:05PM +0200, sahu@mailbox.org wrote:
> 
> And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
> 

The B functions are buffered i/o; see the bio(2) manpage for more.

I have never heard a convincing theory explaining the selection of Q.

khm


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 17:13 ` Kurt H Maier
@ 2022-08-02 17:45   ` Jacob Moody
  2022-08-02 18:41     ` ori
  0 siblings, 1 reply; 9+ messages in thread
From: Jacob Moody @ 2022-08-02 17:45 UTC (permalink / raw)
  To: 9front

On 8/2/22 11:13, Kurt H Maier wrote:
> On Tue, Aug 02, 2022 at 06:51:05PM +0200, sahu@mailbox.org wrote:
>>
>> And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
>>
> 
> The B functions are buffered i/o; see the bio(2) manpage for more.
> 
> I have never heard a convincing theory explaining the selection of Q.
> 
> khm
> 

My thought has been the Q was for uniQue. But that doesn't
seem quite right.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 17:45   ` Jacob Moody
@ 2022-08-02 18:41     ` ori
  2022-08-02 19:34       ` sirjofri
  0 siblings, 1 reply; 9+ messages in thread
From: ori @ 2022-08-02 18:41 UTC (permalink / raw)
  To: 9front

Quoth Jacob Moody <moody@mail.posixcafe.org>:
> On 8/2/22 11:13, Kurt H Maier wrote:
> > On Tue, Aug 02, 2022 at 06:51:05PM +0200, sahu@mailbox.org wrote:
> >>
> >> And since it appears more often in the function, what do "B" (Biobuf, Bfildes, Bterm, ...) and "Q" (Qid) stand for?
> >>
> > 
> > The B functions are buffered i/o; see the bio(2) manpage for more.
> > 
> > I have never heard a convincing theory explaining the selection of Q.
> > 
> > khm
> > 
> 
> My thought has been the Q was for uniQue. But that doesn't
> seem quite right.

Since many of the Unix room staff were either Canadian or
British, I think it stands for Queen's ID.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 18:41     ` ori
@ 2022-08-02 19:34       ` sirjofri
  2022-08-02 19:44         ` Jacob Moody
  0 siblings, 1 reply; 9+ messages in thread
From: sirjofri @ 2022-08-02 19:34 UTC (permalink / raw)
  To: 9front

Maye you should ask the question about Q either the Q continuum, on the 
9fans mailing list or the tuhs list and some of the old unix beards can 
answer? It would be really interesting to know or at least hear their 
thoughts. My theories:

Q is a weird letter that's not often used in the alphabet, unlike a,b,c, 
and a big Q, so it's not a context specific prefix. Compare to, well, B 
for bio-stuff.

Q as in, queue. Maybe at some point they had some kinda queue 
implementation for dynamic filesystems, and the Qid was some kinda 
identifier in that list?

Q as in, star trek. I mean, who knows what they thought, maybe it was 
just some fun idea.

sirjofri

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 19:34       ` sirjofri
@ 2022-08-02 19:44         ` Jacob Moody
  2022-08-02 19:53           ` sahu
  0 siblings, 1 reply; 9+ messages in thread
From: Jacob Moody @ 2022-08-02 19:44 UTC (permalink / raw)
  To: 9front

On 8/2/22 13:34, sirjofri wrote:
> Maye you should ask the question about Q either the Q continuum, on the 
> 9fans mailing list or the tuhs list and some of the old unix beards can 
> answer? It would be really interesting to know or at least hear their 
> thoughts. My theories:
> 
> Q is a weird letter that's not often used in the alphabet, unlike a,b,c, 
> and a big Q, so it's not a context specific prefix. Compare to, well, B 
> for bio-stuff.
> 
> Q as in, queue. Maybe at some point they had some kinda queue 
> implementation for dynamic filesystems, and the Qid was some kinda 
> identifier in that list?
> 
> Q as in, star trek. I mean, who knows what they thought, maybe it was 
> just some fun idea.
> 
> sirjofri


I did some digging, according to Rob it's for unique.

https://9fans.topicbox.com/groups/9fans/T2948a78ca9a0fb64-M4ef3befa1966557106cf1f93/9fans-why-u-h-why-qid


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [9front] question about httpd
  2022-08-02 19:44         ` Jacob Moody
@ 2022-08-02 19:53           ` sahu
  0 siblings, 0 replies; 9+ messages in thread
From: sahu @ 2022-08-02 19:53 UTC (permalink / raw)
  To: 9front

Thank you very much for all the good and helpful answers! :)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-08-02 19:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 16:51 [9front] question about httpd sahu
2022-08-02 16:56 ` Jacob Moody
2022-08-02 17:12 ` ori
2022-08-02 17:13 ` Kurt H Maier
2022-08-02 17:45   ` Jacob Moody
2022-08-02 18:41     ` ori
2022-08-02 19:34       ` sirjofri
2022-08-02 19:44         ` Jacob Moody
2022-08-02 19:53           ` sahu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).