SFTP Server

Roy Tam roytam at gmail.com
Mon Dec 21 13:39:18 WST 2009


Hi all,

For this standalone SFTP server, there's a glitch that makes it
allocates ~32MB virtual memory, the patch below fix this glitch.

--- queue.c.old	2009-12-21 13:17:19.000000000 +0800
+++ queue.c	2009-12-21 13:19:34.000000000 +0800
@@ -75,29 +75,32 @@
   return 0;
 }

 void queue_init(struct queue **qr,
 		const struct queuedetails *details,
 		int nthreads) {
   int n;
   struct queue *q;
+  pthread_attr_t attr;

   q = xmalloc(sizeof *q);
   memset(q, 0, sizeof *q);
   q->jobs = 0;
   q->jobstail = &q->jobs;
   ferrcheck(pthread_mutex_init(&q->m, 0));
   ferrcheck(pthread_cond_init(&q->c, 0));
   q->details = details;
   q->nthreads = nthreads;
   q->threads = xcalloc(nthreads, sizeof (pthread_t));
   q->join = 0;
+  pthread_attr_init(&attr);
+  pthread_attr_setstacksize(&attr,128*1024);
   for(n = 0; n < q->nthreads; ++n)
-    ferrcheck(pthread_create(&q->threads[n], 0, queue_thread, q));
+    ferrcheck(pthread_create(&q->threads[n], &attr, queue_thread, q));
   *qr = q;
 }

 void queue_add(struct queue *q, void *job) {
   struct queuejob *qj;

   qj = xmalloc(sizeof *qj);
   qj->next = 0;


2009/12/8 Roy Tam <roytam at gmail.com>:
> Hi all,
>
> Besides OpenSSH sftp server, I found that Green End SFTP Server works
> with dropbear too. (Python requirement is for test only which can be
> safely removed from configure.ac)
> http://www.greenend.org.uk/rjk/sftpserver/
>
> Best regards,
> Roy
>


More information about the Dropbear mailing list