From owner-state-threads@oss.sgi.com Wed Sep 13 07:18:50 2000 Received: by oss.sgi.com id ; Wed, 13 Sep 2000 07:18:40 -0700 Received: from internal.mail.demon.net ([193.195.224.3]:25754 "EHLO internal.mail.demon.net") by oss.sgi.com with ESMTP id ; Wed, 13 Sep 2000 07:18:24 -0700 Received: from gwhdemnts03.server.demon.net (gwhdemnts03.server.demon.net [193.195.224.75]) by internal.mail.demon.net with ESMTP id PAA10312; Wed, 13 Sep 2000 15:18:22 +0100 (BST) Received: by gwhdemnts03.server.demon.net with Internet Mail Service (5.5.2650.21) id ; Wed, 13 Sep 2000 15:18:22 +0100 Message-ID: <9B16CD9CFF9CD311B782009027D0D39301DB1CDB@gwhdemnts02.server.demon.net> From: "Kiernan, Alex" To: "'state-threads@oss.sgi.com'" Subject: Proxy failure on ECONNABORTED Date: Wed, 13 Sep 2000 15:18:21 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing I was playing with the proxy example with state threads & managed to get one of the processes to die (dual CPU box). Whats happened was the accept() call returned with ECONNABORTED (this is on Solaris 7) which caused the caller to bug out. My immediate reaction was to change if (errno == EINTR) to if (errno == EINTR || errno == ECONNABORTED) in st_accept(), but I'm not convinced thats the right fix (OK it needs some ifdefing around it, but I was thinking more of where this is "the right fix"). -- Alex Kiernan, Principal Engineer, Development, Thus PLC From owner-state-threads@oss.sgi.com Wed Sep 13 13:35:41 2000 Received: by oss.sgi.com id ; Wed, 13 Sep 2000 13:35:21 -0700 Received: from deliverator.sgi.com ([204.94.214.10]:5737 "EHLO deliverator.sgi.com") by oss.sgi.com with ESMTP id ; Wed, 13 Sep 2000 13:34:57 -0700 Received: from nodin.corp.sgi.com (fddi-nodin.corp.sgi.com [198.29.75.193]) by deliverator.sgi.com (980309.SGI.8.8.8-aspam-6.2/980310.SGI-aspam) via ESMTP id NAA09306 for ; Wed, 13 Sep 2000 13:27:16 -0700 (PDT) mail_from (genes@metrostar.engr.sgi.com) Received: from metrostar.engr.sgi.com (metrostar.engr.sgi.com [163.154.38.57]) by nodin.corp.sgi.com (980427.SGI.8.8.8/980728.SGI.AUTOCF) via SMTP id NAA23415 for ; Wed, 13 Sep 2000 13:34:25 -0700 (PDT) Received: (from genes@localhost) by metrostar.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id NAA09625; Wed, 13 Sep 2000 13:13:34 -0700 From: "Gene Shekhtman" Message-Id: <10009131313.ZM9623@metrostar.engr.sgi.com> Date: Wed, 13 Sep 2000 13:13:34 -0700 In-Reply-To: "Kiernan, Alex" "Proxy failure on ECONNABORTED" (Sep 13, 3:18pm) References: <9B16CD9CFF9CD311B782009027D0D39301DB1CDB@gwhdemnts02.server.demon.net> X-Mailer: Z-Mail (3.2.3 08feb96 MediaMail) To: "Kiernan, Alex" Subject: Re: Proxy failure on ECONNABORTED Cc: "'state-threads@oss.sgi.com'" Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing On Sep 13, 3:18pm, Kiernan, Alex wrote: > Subject: Proxy failure on ECONNABORTED > I was playing with the proxy example with state threads & managed to get one > of the processes to die (dual CPU box). Whats happened was the accept() call > returned with ECONNABORTED (this is on Solaris 7) which caused the caller to > bug out. > > My immediate reaction was to change > > if (errno == EINTR) > > to > > if (errno == EINTR || errno == ECONNABORTED) > > in st_accept(), but I'm not convinced thats the right fix (OK it needs some > ifdefing around it, but I was thinking more of where this is "the right > fix"). > I think that applications should deal with those types of errors and not the library. That is, you need to modify proxy.c (which is just an example) to handle ECONNABORTED the way you want it. Something along the lines: .... cli_nfd = st_accept(srv_nfd, (struct sockaddr *)&cli_addr, &n, -1); if (cli_nfd == NULL) { /* Ignore ECONNABORTED */ if (errno == ECONNABORTED) continue; print_sys_error("st_accept"); exit(1); } .... In other words, treat st_accept() the same way as accept(3). Gene -- Gene Shekhtman genes@sgi.com Internet Systems Engineering 650-933-8676 Silicon Graphics, Inc. From owner-state-threads@oss.sgi.com Wed Sep 13 22:16:38 2000 Received: by oss.sgi.com id ; Wed, 13 Sep 2000 22:16:17 -0700 Received: from internal.mail.demon.net ([193.195.224.3]:59867 "EHLO internal.mail.demon.net") by oss.sgi.com with ESMTP id ; Wed, 13 Sep 2000 22:15:58 -0700 Received: from gwhdemnts03.server.demon.net (gwhdemnts03.server.demon.net [193.195.224.75]) by internal.mail.demon.net with ESMTP id GAA00921; Thu, 14 Sep 2000 06:15:44 +0100 (BST) Received: by gwhdemnts03.server.demon.net with Internet Mail Service (5.5.2650.21) id ; Thu, 14 Sep 2000 06:15:43 +0100 Message-ID: <9B16CD9CFF9CD311B782009027D0D39301DB1CE1@gwhdemnts02.server.demon.net> From: "Kiernan, Alex" To: "'Gene Shekhtman'" Cc: "'state-threads@oss.sgi.com'" Subject: RE: Proxy failure on ECONNABORTED Date: Thu, 14 Sep 2000 06:15:43 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing > > My immediate reaction was to change > > > > if (errno == EINTR) > > > > to > > > > if (errno == EINTR || errno == ECONNABORTED) > > > > in st_accept(), but I'm not convinced thats the right fix > (OK it needs some > > ifdefing around it, but I was thinking more of where this > is "the right > > fix"). > > > > I think that applications should deal with those types of > errors and not the > library. That is, you need to modify proxy.c (which is just > an example) > to handle ECONNABORTED the way you want it. Something along > the lines: > > .... > cli_nfd = st_accept(srv_nfd, (struct sockaddr > *)&cli_addr, &n, -1); > if (cli_nfd == NULL) { > /* Ignore ECONNABORTED */ > if (errno == ECONNABORTED) > continue; > print_sys_error("st_accept"); > exit(1); > } > .... > > In other words, treat st_accept() the same way as accept(3). > Thanks, that was the steer I needed. -- Alex Kiernan, Principal Engineer, Development, Thus PLC From owner-state-threads@oss.sgi.com Mon Sep 18 10:45:11 2000 Received: by oss.sgi.com id ; Mon, 18 Sep 2000 10:45:02 -0700 Received: from multivac.xs4all.nl ([194.109.254.17]:33009 "EHLO helena.tux.nu") by oss.sgi.com with ESMTP id ; Mon, 18 Sep 2000 10:44:29 -0700 Received: from helena (IDENT:matthijs@localhost [127.0.0.1]) by helena.tux.nu (8.9.3/8.8.7) with SMTP id TAA05115 for ; Mon, 18 Sep 2000 19:45:22 +0200 From: Matthijs Sypkens Smit To: state-threads@oss.sgi.com Subject: problem with unpredictable values of variable Date: Mon, 18 Sep 2000 19:45:21 +0200 X-Mailer: KMail [version 1.1.94] Content-Type: text/plain MIME-Version: 1.0 Message-Id: <00091819452102.04770@helena> Content-Transfer-Encoding: 8bit Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing Hi all, I'm very interested in using the state-threads library or actually the server-example that's implemented with this library, but I'm experiencing some troubles. I have quite some experience in coding C, but little experience with either threads or tcp/ip programming in C. The problem is this: I've tried to modifiy the server example to be able to return inputted strings in uppercase. Herefor I changed handle_session(...) to look like this: --- void handle_session(long srv_socket_index, st_netfd_t cli_nfd) { char buf[512]; struct in_addr *from = st_netfd_getspecific(cli_nfd); if (st_read(cli_nfd, buf, sizeof(buf), SEC2USEC(REQUEST_TIMEOUT)) < 0) { err_sys_report(errfd, "WARN: can't read request from %s: st_read", inet_ntoa(*from)); return; } if (st_write(cli_nfd, to_uppercase(buf), strlen(buf), -1) == -1) { err_sys_report(errfd, "WARN: can't write response to %s: st_write", inet_ntoa(*from)); return; } RQST_COUNT(srv_socket_index)++; } --- and added the function: --- char* to_uppercase(char *string) { int i; for (i = 0; string[i] != '\0'; i++) string[i] = toupper(string[i]); return string; } --- This seemed to work at first, but today I discovered that the array of characters `buf' sometimes later on contained text I had inputted earlier, but in uppercase. I suspect that I'm either making a dumb mistake or are totally missing some vital concept here. Might using '\0' not be a smart way to determine the end of a string or am I making some off-by-one error which causes this? To further demonstrate the problem, the following examples: An example of a working session is: --- [matthijs@helena /tmp]$ telnet helena 8000 Trying 192.168.79.13... Connected to helena. Escape character is '^]'. test TEST Connection closed by foreign host. --- Sometimes something like this happens: --- [matthijs@helena /tmp]$ telnet helena 8000 Trying 192.168.79.13... Connected to helena. Escape character is '^]'. test TEST T IS EEN MEGA-LANGE-TEST. EENS ZIEN WAT HIER GAAT GEBEUREN Connection closed by foreign host. --- Here `T IS EEN MEGA-LANGE-TEST. EENS ZIEN WAT HIER GAAT GEBEUREN' is something I typed in earlier in lowercase. I don't understand why this would happen and I'm not even sure that this has to do with (the threading of) the state-threads library. I sure hope someone can shed some light at this problem. TIA, -- Matthijs From owner-state-threads@oss.sgi.com Mon Sep 18 13:12:02 2000 Received: by oss.sgi.com id ; Mon, 18 Sep 2000 13:11:52 -0700 Received: from deliverator.sgi.com ([204.94.214.10]:47202 "EHLO deliverator.sgi.com") by oss.sgi.com with ESMTP id ; Mon, 18 Sep 2000 13:11:31 -0700 Received: from metrostar.engr.sgi.com (metrostar.engr.sgi.com [163.154.38.57]) by deliverator.sgi.com (980309.SGI.8.8.8-aspam-6.2/980310.SGI-aspam) via SMTP id NAA22407 for ; Mon, 18 Sep 2000 13:03:49 -0700 (PDT) mail_from (genes@metrostar.engr.sgi.com) Received: (from genes@localhost) by metrostar.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id MAA16002; Mon, 18 Sep 2000 12:51:48 -0700 From: "Gene Shekhtman" Message-Id: <10009181251.ZM16000@metrostar.engr.sgi.com> Date: Mon, 18 Sep 2000 12:51:48 -0700 In-Reply-To: Matthijs Sypkens Smit "problem with unpredictable values of variable" (Sep 18, 7:45pm) References: <00091819452102.04770@helena> X-Mailer: Z-Mail (3.2.3 08feb96 MediaMail) To: Matthijs Sypkens Smit Subject: Re: problem with unpredictable values of variable Cc: state-threads@oss.sgi.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing On Sep 18, 7:45pm, Matthijs Sypkens Smit wrote: > Subject: problem with unpredictable values of variable > .... > > The problem is this: > I've tried to modifiy the server example to be able to return inputted > strings in uppercase. Herefor I changed handle_session(...) to look like this: > --- > void handle_session(long srv_socket_index, st_netfd_t cli_nfd) { > char buf[512]; > > struct in_addr *from = st_netfd_getspecific(cli_nfd); > > if (st_read(cli_nfd, buf, sizeof(buf), SEC2USEC(REQUEST_TIMEOUT)) < 0) { > err_sys_report(errfd, "WARN: can't read request from %s: st_read", > inet_ntoa(*from)); > return; > } > > if (st_write(cli_nfd, to_uppercase(buf), strlen(buf), -1) == -1) { > err_sys_report(errfd, "WARN: can't write response to %s: st_write", > inet_ntoa(*from)); > return; > } > > RQST_COUNT(srv_socket_index)++; > } > --- > and added the function: > --- > char* to_uppercase(char *string) { > int i; > > for (i = 0; string[i] != '\0'; i++) > string[i] = toupper(string[i]); > > return string; > } > --- > > This seemed to work at first, but today I discovered that the array of > characters `buf' sometimes later on contained text I had inputted earlier, > but in uppercase. I suspect that I'm either making a dumb mistake or are > totally missing some vital concept here. > Matthijs, The st_read() function (just like read(2)) returns the number of bytes read and doesn't do '\0'-termination. If you want to manipulate `buf' as a string, you need to terminate it yourself: void handle_session(long srv_socket_index, st_netfd_t cli_nfd) { char buf[512]; int n; struct in_addr *from = st_netfd_getspecific(cli_nfd); if ((n = st_read(cli_nfd, buf, sizeof(buf), SEC2USEC(REQUEST_TIMEOUT))) < 0) { err_sys_report(errfd, "WARN: can't read request from %s: st_read", inet_ntoa(*from)); return; } /* '\0'-terminate the buffer */ buf[n] = '\0'; if (st_write(cli_nfd, to_uppercase(buf), strlen(buf), -1) == -1) { err_sys_report(errfd, "WARN: can't write response to %s: st_write", inet_ntoa(*from)); return; } RQST_COUNT(srv_socket_index)++; } Hope it helps, Gene -- Gene Shekhtman genes@sgi.com Internet Systems Engineering 650-933-8676 Silicon Graphics, Inc. From owner-state-threads@oss.sgi.com Mon Sep 25 15:07:37 2000 Received: by oss.sgi.com id ; Mon, 25 Sep 2000 15:07:27 -0700 Received: from multivac.xs4all.nl ([194.109.254.17]:28666 "EHLO helena.tux.nu") by oss.sgi.com with ESMTP id ; Mon, 25 Sep 2000 15:07:08 -0700 Received: from helena (IDENT:matthijs@localhost [127.0.0.1]) by helena.tux.nu (8.9.3/8.8.7) with SMTP id AAA06416 for ; Tue, 26 Sep 2000 00:08:03 +0200 From: Matthijs Sypkens Smit To: state-threads@oss.sgi.com Subject: per-thread global variables Date: Tue, 26 Sep 2000 00:08:01 +0200 X-Mailer: KMail [version 1.1.94.2] Content-Type: text/plain MIME-Version: 1.0 Message-Id: <00092600080101.06092@helena> Content-Transfer-Encoding: 8bit Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing Hi all, I'm currently working on a project to create a client-server implementation of a differential equation analysis tool. It is supposed to be a combination of a Java applet for defining, showing en editing systems and a deamon for providing methods of integration and computing-power. Since it must be able to handle more connections (by different users) simultaneously, I thought the state thread lib would be very useful for this. I took the server-example and played with it a little, which brought me to the following question: What is the best way to handle data that is needed by many functions, but is different on a connection basis? I'll expand on that. As long as the user is logged in on the server with the applet, there's an open connection which provides for a permanent/continous means of communcation. Once the connection is established many variables have to kept track of, for instance the definitions of multiple systems of differential equations and their solutions. Every user can input his own systems so every thread that handles a connection has a different set of data (which is different in size as well). A great deal of this data needs to be accessed by many routines. To me it looks therefor logical to have this data global to every controling thread, but not to the others. What are my options? I don't think it's possible to just define globals in my redefinition of handle_connection() (in a seperate c-file), because --if I understand things correctly-- this data would be the same for every thread. I saw in the documentation a section "Per-Thread Private Data" with four routines probably exactly for this issue. Is this what I need or are there other options? Is using these methods practical even for large amount of data (variables)? (and how does that actually work? I'm not sure I understand...) The last option I can conceive of is passing all the necessary variables to the routines that need them. Might it be a sign of bad design if this seems to over-complicate the code with many function-parameters? At this time it's hard to say how many variables actually need to be passed to how many funtions and what the level of (im)practicality is, because this still needs to be evaluated. I'm not sure yet how big a problem this might pose. This might be more of a issue of the C language than of the state-thread library, but considering that there're some people around here with experience in this field I took my chances. I know that it might be hard to say something about this, considering you don't have a detailed idea of how things are supposed to work and so on, but any insights and/or comments are appreciated, TIA, -- Matthijs ** Do you know EVERYthing there is to know about your idol? ** Check it out: http://www.fanpagesindex.com/ From owner-state-threads@oss.sgi.com Mon Sep 25 16:25:59 2000 Received: by oss.sgi.com id ; Mon, 25 Sep 2000 16:25:49 -0700 Received: from deliverator.sgi.com ([204.94.214.10]:43595 "EHLO deliverator.sgi.com") by oss.sgi.com with ESMTP id ; Mon, 25 Sep 2000 16:25:15 -0700 Received: from trudge.engr.sgi.com (trudge.engr.sgi.com [163.154.38.51]) by deliverator.sgi.com (980309.SGI.8.8.8-aspam-6.2/980310.SGI-aspam) via ESMTP id QAA11324 for ; Mon, 25 Sep 2000 16:17:01 -0700 (PDT) mail_from (mja@trudge.engr.sgi.com) Received: (from mja@localhost) by trudge.engr.sgi.com (980427.SGI.8.8.8/970903.SGI.AUTOCF) id QAA63320; Mon, 25 Sep 2000 16:22:26 -0700 (PDT) From: mja@trudge.engr.sgi.com (Mike Abbott) Message-Id: <200009252322.QAA63320@trudge.engr.sgi.com> Subject: Re: per-thread global variables To: matthijs@helena.tux.nu (Matthijs Sypkens Smit) Date: Mon, 25 Sep 2000 16:22:26 -0700 (PDT) Cc: state-threads@oss.sgi.com In-Reply-To: <00092600080101.06092@helena> from "Matthijs Sypkens Smit" at Sep 26, 2000 12:08:01 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing > I'm currently working on a project to create a client-server implementation > of a differential equation analysis tool. > [...] Sounds like you want to use thread-specific data. Put all the data for each connection in a struct and store a pointer to it as TSD. -- Michael J. Abbott mja@sgi.com http://reality.sgi.com/mja/ From owner-state-threads@oss.sgi.com Thu Sep 28 19:37:29 2000 Received: by oss.sgi.com id ; Thu, 28 Sep 2000 19:37:20 -0700 Received: from deliverator.sgi.com ([204.94.214.10]:38003 "EHLO deliverator.sgi.com") by oss.sgi.com with ESMTP id ; Thu, 28 Sep 2000 19:36:57 -0700 Received: from metrostar.engr.sgi.com (metrostar.engr.sgi.com [163.154.38.57]) by deliverator.sgi.com (980309.SGI.8.8.8-aspam-6.2/980310.SGI-aspam) via SMTP id TAA23899 for ; Thu, 28 Sep 2000 19:29:13 -0700 (PDT) mail_from (genes@metrostar.engr.sgi.com) Received: (from genes@localhost) by metrostar.engr.sgi.com (950413.SGI.8.6.12/960327.SGI.AUTOCF) id TAA11216 for state-threads@oss.sgi.com; Thu, 28 Sep 2000 19:10:18 -0700 From: "Gene Shekhtman" Message-Id: <10009281910.ZM11214@metrostar.engr.sgi.com> Date: Thu, 28 Sep 2000 19:10:18 -0700 X-Mailer: Z-Mail (3.2.3 08feb96 MediaMail) To: state-threads@oss.sgi.com Subject: ST 1.1-dev Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-state-threads@oss.sgi.com Precedence: bulk Return-Path: X-Orcpt: rfc822;state-threads-outgoing The snapshot of the current ST source tree is now available as a development version (st-1.1-dev). Please see the ChangeLog.txt file for changes since version 1.0. There are no serious bug fixes (none reported), so if you are not interested in Linux IA-64 port or performance profiling on IRIX, you don't need to upgrade. http://oss.sgi.com/projects/state-threads/download/ As always, your contributions and comments are welcome. -- Gene Shekhtman genes@sgi.com Internet Systems Engineering 650-933-8676 Silicon Graphics, Inc.