From owner-soc-status@FreeBSD.ORG Tue Jul 2 09:23:53 2013 Return-Path: Delivered-To: soc-status@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BE2C7775 for ; Tue, 2 Jul 2013 09:23:53 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) by mx1.freebsd.org (Postfix) with ESMTP id 933F91F63 for ; Tue, 2 Jul 2013 09:23:53 +0000 (UTC) Received: from [192.168.0.2] (cpc27-cmbg15-2-0-cust235.5-4.cable.virginmedia.com [86.27.188.236]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id r629NptU072077 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 2 Jul 2013 09:23:52 GMT (envelope-from theraven@FreeBSD.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: IDMS : Weekly status report #2 of 14 From: David Chisnall In-Reply-To: Date: Tue, 2 Jul 2013 10:23:46 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Ambarisha B X-Mailer: Apple Mail (2.1503) Cc: soc-status@FreeBSD.org X-BeenThere: soc-status@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Summer of Code Status Reports and Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jul 2013 09:23:53 -0000 On 1 Jul 2013, at 19:27, Ambarisha B wrote: > 3. Refactor the client to give an open fd to the server (instead of > expecting one, as is the model with libfetch) Can you explain a bit what this means? The daemon should be the thing = openning the connection. The forked worker should then pass it to = libfetch. The code in the daemon should look something approximately = like this: struct client_request req; int IPC_connection_to_clients =3D /* whatever you're using here, most = likely a UNIX domain socket so that you can pass in the fd for the = output file from the client. */; while (wait_for_request(IPC_connection_to_clients, &req) { /* URL parsing code goes here. */ int fd server =3D connect(...); /* Error handling goes here */ /* You may want to create a pipe here for sending progress = messages from the client back to the server */ /* You may want to queue requests and not start downloading = immediately if some bandwidth or number of concurrent downloads quota is = reached */ /* Create the worker */ pid_t child =3D fork(); /* Error handling here */ if (child =3D=3D 0) { /* Now we're in the worker, close any file descriptors = that we shouldn't have */ close(IPC_connection_to_clients); close(stdin); close(stdout); /* Then enter sandboxed mode */ cap_enter(); /* Now do the real downloading and exit */ do_the_real_downloading(server, req.output_file, = req.url); exit(0); } else { /* Close the file descriptors that the worker is using. = */ close(server); close(req.output_file); /* Probably add child to a list of things that you'll = wait for exit signals from in the kqueue call in the wait_for_request = part */ } } David