Unix
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Unix

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 24th, 2008, 12:49 PM
zhengda
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The patch of glibc which allows the user to override the pfinetserver

Hi,

I modified the code of glibc, so the user can override the default
pfinet server by using the environment variable.
Here is the patch:
glibc-2.7-old/hurd/hurdsock.c 2008-06-21 01:38:30.040000000 +0200
glibc-2.7/hurd/hurdsock.c 2008-06-21 01:45:28.340000000 +0200
@@ -76,6 +76,30 @@

if (domain max_domain || servers[domain] == MACH_PRT_NULL)
{
+ char *sock_serv_path=NULL;
+ int len;
+ char *name=NULL;
+ char *np=NULL;
+ sock_serv_path=getenv("SCK_SERV_PATH");
+ if(sock_serv_path == NULL)
+ sock_serv_path=_SERVERS_SCKET;
+ len=strlen(sock_serv_path);
+ name=(char *)malloc(len+100);
+ if(name == NULL)
+ __libc_fatal ("hurd: Can't allocate the socket server path\n");
+ np=&name[len+100];
+ * = '\0';
+ np = _itoa (domain, np, 10, 0);
+ * = '/';
+
+ np -= len;
+ memcpy (np, sock_serv_path , len);
+
+ server = __file_name_lookup (np, 0, 0);
+ if (domain <= max_domain)
+ servers[domain] = server;
+ free(name);
+#if 0
char name[sizeof (_SERVERS_SCKET) + 100];
char *np = &name[sizeof (name)];
* = '\0';
@@ -86,6 +110,7 @@
server = __file_name_lookup (np, 0, 0);
if (domain <= max_domain)
servers[domain] = server;
+#endif
}
else
server = servers[domain];

Any comments?

Best,
Zheng Da

Reply With Quote
  #2  
Old June 25th, 2008, 12:30 PM
zhengda
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The patch of glibc which allows the user to override the pfinetserver

Neal H. Walfield wrote:
This works in the case where you want to override all pf servers.
This case is important. Also important is the ability to override a
single pf server in a similar manner.
>

A couple comments on the code: please follow the GNU coding standards.
Second, I assume that you left the #if 0 in because you are requesting
review. Make sure that you remove this when you really intend to
submit the patch. Finally, when that happens, make sure to include a
change log entry.
>

Neal

I wonder if it's really necessary to override a single pf server.
If more network protocols are implemented, we have to provide more
environment variables for the servers.
the other hand, if we override the path of all socket servers, we can
create a symbolic link to the default server which we don't want to
override.
Anyway, I provide two more environment variables SCK_INET_SERV_PATH and
SCK_LCAL_SERV_PATH for the pfinet server and pflocal server, respectively.
I try to make my code meet the GNU coding standard. If it doesn't, could
you point it out.
The GNU coding standard is a bit long, so I'm not sure if my code meets
all GNU standards.

Here is the patch of the second version

glibc-2.7-old/hurd/hurdsock.c 2008-06-21 01:38:30.000000000 +0200
/glibc-2.7/hurd/hurdsock.c 2008-06-24 12:55:23.000000000 +0200
@@ -76,16 +76,39 @@

if (domain max_domain || servers[domain] == MACH_PRT_NULL)
{
- char name[sizeof (_SERVERS_SCKET) + 100];
- char *np = &name[sizeof (name)];
- * = '\0';
- np = _itoa (domain, np, 10, 0);
- * = '/';
- np -= sizeof (_SERVERS_SCKET) - 1;
- memcpy (np, _SERVERS_SCKET, sizeof (_SERVERS_SCKET) - 1);
+ char *sock_serv_path = NULL;
+ int len;
+ char *name = NULL;
+ char *np = NULL;
+ if ((domain == AF_INET
+ && (sock_serv_path = getenv ("SCK_INET_SERV_PATH")))
+ || (domain == AF_LCAL
+ && (sock_serv_path = getenv ("SCK_LCAL_SERV_PATH"))))
+ {
+ np = sock_serv_path;
+ }
+ else
+ {
+ sock_serv_path = getenv ("SCK_SERV_PATH");
+ if (sock_serv_path == NULL)
+ sock_serv_path = _SERVERS_SCKET;
+ len = strlen (sock_serv_path);
+ name = (char *)malloc (len + 100);
+ if (name == NULL)
+ __libc_fatal ("hurd: Can't allocate the socket server path\n");
+ np = &name[len + 100];
+ * = '\0';
+ np = _itoa (domain, np, 10, 0);
+ * = '/';
+ np -= len;
+ memcpy (np, sock_serv_path , len);
+ }
+
server = __file_name_lookup (np, 0, 0);
if (domain <= max_domain)
- servers[domain] = server;
+ servers[domain] = server;
+ if (name)
+ free(name);
}
else
server = servers[domain];

Best,
Zheng Da

Reply With Quote
  #3  
Old June 26th, 2008, 05:30 PM
Samuel Thibault
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The patch of glibc which allows the user to override the pfinetserver

zhengda, le Thu 26 Jun 2008 19:31:12 +0200, a :
>Hm Something seems wrong with the indentation here -- but it looks as
>if it has been already wrong in the original code Can you fix that
>please?
>
>, and of course you still need a changelog entry. There is a section
>in the GCS on that as well


Where should I write the changelog? in the patch?

Put it at the top of the patch yes. Make sure you have read the GNU
documentation about ChangeLogs: they are meant to be a mere summary of
what modifications the patch does, not of its goal. Read previous
ChangeLog entries for samples.

Samuel

Reply With Quote
  #4  
Old July 4th, 2008, 08:00 PM
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The patch of glibc which allows the user to override thepfinet server

Hi,

Wed, Jul 02, 2008 at 08:42:43PM +0200, zhengda wrote:

The new version of the patch is below.

Hm, what about dropping/replacing the "_PATH" bit, as discussed in the
other subthread?

I wonder if I can use __snprintf(). The code in the original glibc
doesn't use it.

I'm not a glibc hacker; but I would be very surprised if it was a
problem

+ __snprintf (sock_serv_env_name, 30, "SCK_SERV_%d_PATH", domain);

I'd say use "sizeof sock_serv_env_name", rather than hard-coding 30, for
better robustness

-antrik-

Reply With Quote
  #5  
Old July 10th, 2008, 08:00 PM
Samuel Thibault
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
The patch of glibc which allows the user to override the pfinetserver

Hello,

+ char sock_serv_env_name[30];

To avoid a fixed-sized buffer you could use __asprintf.

+ name = (char *)malloc (len + 100);

Use __asprintf here too.

- servers[domain] = server;
+ servers[domain] = server;

Spurious hook, please try to minimize these.

About the ChangeLog entry, it needs to be more precise: add the
environment variable and macro _names_ since that's what people would
grep for.

Samuel

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Unix > The patch of glibc which allows the user to override the pfinetserver


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT