Fix lm3s ftp upload problem

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@199 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
qiuyiuestc 2009-12-13 16:07:36 +00:00
parent bd533b3743
commit bf8bb9db6a
3 changed files with 15 additions and 6 deletions

View File

@ -86,7 +86,7 @@
/* the max number of mounted filesystem */ /* the max number of mounted filesystem */
#define DFS_FILESYSTEMS_MAX 1 #define DFS_FILESYSTEMS_MAX 1
/* the max number of opened files */ /* the max number of opened files */
#define DFS_FD_MAX 2 #define DFS_FD_MAX 4
/* the max number of cached sector */ /* the max number of cached sector */
#define DFS_CACHE_MAX_NUM 4 #define DFS_CACHE_MAX_NUM 4
@ -112,6 +112,9 @@
/* the number of simulatenously active TCP connections*/ /* the number of simulatenously active TCP connections*/
#define RT_LWIP_TCP_PCB_NUM 5 #define RT_LWIP_TCP_PCB_NUM 5
/* Ethernet padding size */
#define RT_LWIP_ETH_PAD_SIZE 2
/* TCP sender buffer space*/ /* TCP sender buffer space*/
#define RT_LWIP_TCP_SND_BUF 1500 #define RT_LWIP_TCP_SND_BUF 1500
/* Enable SNMP protocol*/ /* Enable SNMP protocol*/

View File

@ -165,7 +165,8 @@ int efs_open(struct dfs_fd* file)
efsdir = (DirList*)rt_malloc(sizeof(DirList)); efsdir = (DirList*)rt_malloc(sizeof(DirList));
if(efsdir == RT_NULL) if(efsdir == RT_NULL)
{ {
dfs_log(DFS_DEBUG_INFO, ("memory alloc failed")); dfs_log(DFS_DEBUG_ERROR, ("memory alloc failed"));
rt_free(efsdir);
return -DFS_STATUS_ENOMEM; return -DFS_STATUS_ENOMEM;
} }
@ -186,7 +187,7 @@ int efs_open(struct dfs_fd* file)
efsfile = (File *)rt_malloc(sizeof(File)); efsfile = (File *)rt_malloc(sizeof(File));
if (efsfile == RT_NULL) if (efsfile == RT_NULL)
{ {
dfs_log(DFS_DEBUG_INFO, ("memory alloc failed")); dfs_log(DFS_DEBUG_ERROR, ("memory alloc failed"));
return -DFS_STATUS_ENOMEM; return -DFS_STATUS_ENOMEM;
} }

View File

@ -262,6 +262,7 @@ int do_list(char* directory, int sockfd)
} }
} }
closedir(dirp);
return 0; return 0;
} }
@ -288,6 +289,7 @@ int do_simple_list(char* directory, int sockfd)
send(sockfd, line_buffer, line_length, 0); send(sockfd, line_buffer, line_length, 0);
} }
closedir(dirp);
return 0; return 0;
} }
@ -351,6 +353,7 @@ int ftp_process_request(struct ftp_session* session, char *buf)
} }
else if (strcmp(parameter_ptr, FTP_USER) == 0) else if (strcmp(parameter_ptr, FTP_USER) == 0)
{ {
session->is_anonymous = RT_FALSE;
rt_sprintf(sbuf, "331 Password required for %s\r\n", parameter_ptr); rt_sprintf(sbuf, "331 Password required for %s\r\n", parameter_ptr);
send(session->sockfd, sbuf, strlen(sbuf), 0); send(session->sockfd, sbuf, strlen(sbuf), 0);
} }
@ -552,10 +555,12 @@ err1:
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_SET(session->pasv_sockfd, &readfds); FD_SET(session->pasv_sockfd, &readfds);
rt_kprintf("Waiting %d seconds for data...\n", tv.tv_sec); rt_kprintf("Waiting %d seconds for data...\n", tv.tv_sec);
while(select(0, &readfds, 0, 0, &tv)>0 ) while(select(session->pasv_sockfd+1, &readfds, 0, 0, &tv)>0 )
{ {
if((numbytes=recv(session->pasv_sockfd, sbuf, FTP_BUFFER_SIZE, 0))>0) if((numbytes=recv(session->pasv_sockfd, sbuf, FTP_BUFFER_SIZE, 0))>0)
{
write(fd, sbuf, numbytes); write(fd, sbuf, numbytes);
}
else if(numbytes==0) else if(numbytes==0)
{ {
close(fd); close(fd);