[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference pamsrc::objectbroker

Title:ObjectBroker - BEA Systems' CORBA
Notice:See note 3 for kits; note 5 for training; note 1134 for releases
Moderator:TLE::PARODId
Created:Tue Jul 11 1989
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1413
Total number of notes:6391

1234.0. "[Q]:oneway operation is blocked ?" by OSAOS3::INOGUCHI () Fri May 31 1996 10:08

T.RTitleUserPersonal
Name
DateLines
1234.1OSANPO::NOSETooru Nosse, SI/Japan West PSC/OS2-1Fri May 31 1996 11:1310
1234.2Request_Invoke VS Request_SendPUXGPX::LHERAULTYves - PSC Paris - FranceFri Jul 19 1996 13:0417
1234.3REQUE::BOWERPeter Bower, ObjectBrokerTue Jul 23 1996 10:517
1234.4Same problem here !!TAEC::BALLADELLISurfing with the AlienFri Aug 02 1996 17:0521
1234.5This is QAR#03364TAEC::SABIANIWed Sep 04 1996 07:440
1234.6LEMAN::DONALDSONFroggisattva! Froggisattva!Mon Mar 03 1997 08:4918
What's the status of this?

We generate C++ stubs for v2.7-11 on NT4.
We have *lots* of oneways. The generated code
sets flags differently for oneways (it sets
a NO_RESPONSE flag). It then calls ::invoke.

These so-called oneway requests block. If we change
the ::invoke to ::send_oneway then the requests
proceed as expected.

Should we understand that the generated code is wrong?

We have now put in place another program to fix-up
the generated code - for stubs this time. (We already
fix-up the iml and the imh).

John D.
1234.7REQUE::BOWERPeter Bower, ObjectBrokerThu Mar 06 1997 10:473
    The corresponding PTR is PTR  16-3-141. It has not yet
    been fixed.
    
1234.8Program to fix the client stub file.UTROP1::OLERUD_GMon Mar 10 1997 05:33186
    Peter,
    
    I have made a fix program to fix the generated client stub file. It is
    very easy to write. It reads the .cxx stub file, searches for the
    string "CORBA_INV_NO_RESPONSE | OBB_INVOKE_DEFERRED", then looks for
    the corresponding _request->invoke and replaces it by
    _request->send_oneway. The code follows below:
    
    
    /*
     *
     * StubFix - a program to fixup ObjectBroker stub files
     *
     * This program uses the STL.
     *
     *	Description:
     *		This program reads in an stub file and changes the
    _request->invoke (ev) to
     *		_request->send_oneway (ev) if the interface is declared as
    oneway.
     *
     *
     *	Authors: Olerud,	27 Feb 1997
     *
     *	History:
     *		27 Feb	1997	Gunnar Olerud, First version
     *
     */
    
    #ifdef WIN32
    #pragma warning (disable: 4786)	// identifier was truncated to
    '255' characters
    #endif
    #include <string>
    #include <vector>
    #include <map>
    #include <iostream>
    #include <fstream>
    
    #define MAX_LINE_SIZE	512
    
    vector <string, allocator<string> > Lines; // header from the default
    IML file
    
    typedef map <string, string, less<string>, allocator<string> >
    KeywordMap;
    KeywordMap	keywords;
    
    // Forward declarations
    bool ParseFile (string filename, vector <string, allocator<string> >
    *pLines);
    bool creOutputFile(string fileName, vector <string, allocator<string> >
    *pLines);
    bool fixupOneway( vector <string, allocator<string> > *pLines);
    
    // Here it comes! The main program.
    int
    main(int argc, char *argv[])
    {
    	if (argc < 2)
    	{
    		cout << "StubFix: Not enough parameters, syntax:" << endl;
    		cout << "StubFix <stub file>" << endl;
    		return 1;
    	}
    
    	// define the set of special keywords for single-line lines.
    	keywords["Oneway"] = "CORBA_INV_NO_RESPONSE | OBB_INVOKE_DEFERRED";
    
    	// read the IMH files into a vector
    	if (!ParseFile (argv[1], &Lines))
    	{
    		return 1;
    	}
    
    	if (!fixupOneway( &Lines))
    	{
    		cout << "No changes made" << endl;
    		return 0;
    	}
    	// output the default vector to the new IML file
    	creOutputFile(argv[1], &Lines);
    	return 0;
    }
    
    bool 
    ParseFile (string fileName, vector <string, allocator<string> >
    *pLines)
    {
    	char line[MAX_LINE_SIZE];
    
    	ios_base::openmode mode = ios_base::in;
    	ifstream infile (fileName.c_str(), mode);
    	if (!infile.is_open())
    	{
    		cout << "StubFix: Can't open file '" << fileName << "'" <<
    endl;
    		return false;
    	}
    
    	cout << "Reading from file " << fileName << endl;
    
    	while (infile.getline (line, sizeof(line)))
    	{
    		pLines->push_back(line);		
    	} // while (infile.getline (line, sizeof(line)))
    	infile.close ();
    
    	return true;
    }
    
                
    bool
    creOutputFile(string fileName, vector <string, allocator<string> >
    *pLines)
    {
    #ifdef WIN32
    	ofstream fileout (fileName.c_str());
    	if (!fileout.is_open())
    #else
    	ofstream fileout (fileName.c_str());
    	if (!fileout.rdbuf()->is_open())
    #endif
    	{
    		cout << "imhFix: Can't create file '" << fileName << "'" <<
    endl;
    		return false;
    	}
    
    	cout << "Writing to file " << fileName << endl;
    
    
    
    	vector <string, allocator<string> >::iterator lineIT;
    	for (lineIT = pLines->begin(); lineIT != pLines->end(); lineIT++)
    	{
    		fileout << (*lineIT) << endl;
    	}
    
    	fileout.close();
    	return true;
    } // End of creOutputIMHFile()
    
    
    bool
    fixupOneway( vector <string, allocator<string> > *pLines)
    { 
    	int position;
    	bool isChanged = false;
    	vector <string, allocator<string> >::iterator lineIT, replaceIT;
    
    	KeywordMap::iterator it;
    	if ((it = keywords.find ("Oneway")) == keywords.end())
    	{
    		cout << "StubFix: Can't find keyword for Oneway " << endl;
    		return false;
    	}
    
    	string key = (*it).second;
    	cout << "Replacing _request->invoke to _request->send_oneway where
    appropriate" << endl;
    	for (lineIT = pLines->begin(); lineIT != pLines->end(); lineIT++)
    	{
    		//destructor found. Add the virtual keyword if it is not
    there.
    		if ((position = (*lineIT).find(key)) > 0)
    		{
    			for (replaceIT = lineIT + 1; replaceIT !=
    pLines->end(); replaceIT++)
    			{
    				if ((position =
    (*replaceIT).find("_request->invoke")) > 0)
    				{
    					(*replaceIT).replace
    ((*replaceIT).find("invoke"), 6, "send_oneway");
    					isChanged = true;
    					break;
    				}
    			}
    		}
    	}
    	return isChanged;
    
    } // end of fixupLines