/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* Test: zerolen.c
*
* Description: a test for Bugzilla bug #17699. We perform
* the same test for PR_Writev, PR_Write, and PR_Send. In
* each test the server thread first fills up the connection
* to the client so that the next write operation will fail
* with EAGAIN. Then it calls PR_Writev, PR_Write, or PR_Send
* with a zero-length buffer. The client thread initially
* does not read so that the connection can be filled up.
* Then it empties the connection so that the server thread's
* PR_Writev, PR_Write, or PR_Send call can succeed.
*
* Bug #17699 is specific to the pthreads version on Unix,
* so on other platforms this test does nothing.
*/
#ifndef XP_UNIX
#include <stdio.h>
int main()
{
printf("PASS\n");
return 0;
}
#else /* XP_UNIX */
#include "nspr.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
{
sock = PR_NewTCPSocket();
exit(1);
}
exit(1);
}
exit(1);
}
/*
* Sleep 5 seconds to force the server thread to get EAGAIN.
*/
exit(1);
}
/*
* Then start reading.
*/
/* empty loop body */
}
if (-1 == nbytes) {
exit(1);
}
exit(1);
}
}
int main()
{
int osfd;
if (NULL == listenSock) {
exit(1);
}
exit(1);
}
exit(1);
}
/* Find out what port number we are bound to. */
exit(1);
}
exit(1);
}
/*
* First test PR_Writev.
*/
if (NULL == clientThread) {
exit(1);
}
if (NULL == acceptSock) {
exit(1);
}
/* empty loop body */
}
exit(1);
}
printf("calling PR_Writev with a zero-length buffer\n");
if (nbytes != 0) {
exit(1);
}
exit(1);
}
exit(1);
}
/*
* Then test PR_Write.
*/
if (NULL == clientThread) {
exit(1);
}
if (NULL == acceptSock) {
exit(1);
}
/* empty loop body */
}
exit(1);
}
printf("calling PR_Write with a zero-length buffer\n");
if (nbytes != 0) {
exit(1);
}
exit(1);
}
exit(1);
}
/*
* Finally test PR_Send.
*/
if (NULL == clientThread) {
exit(1);
}
if (NULL == acceptSock) {
exit(1);
}
/* empty loop body */
}
exit(1);
}
printf("calling PR_Send with a zero-length buffer\n");
if (nbytes != 0) {
exit(1);
}
exit(1);
}
exit(1);
}
exit(1);
}
printf("PASS\n");
return 0;
}
#endif /* XP_UNIX */